当前位置: 首页>>代码示例>>Python>>正文


Python DbManager.create_database方法代码示例

本文整理汇总了Python中frappe.model.db_schema.DbManager.create_database方法的典型用法代码示例。如果您正苦于以下问题:Python DbManager.create_database方法的具体用法?Python DbManager.create_database怎么用?Python DbManager.create_database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frappe.model.db_schema.DbManager的用法示例。


在下文中一共展示了DbManager.create_database方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_database_and_user

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import create_database [as 别名]
def create_database_and_user(force, verbose):
	db_name = frappe.local.conf.db_name
	db_name=db_name[:16]
	if "." in db_name: 
		dn=db_name.split('.')
		db_name=dn[0]
	dbman = DbManager(frappe.local.db)
	#print db_name
	#print dbman.get_database_list()
	if force or (db_name not in dbman.get_database_list()):
		#print "in if"
		dbman.delete_user(db_name)
		dbman.drop_database(db_name)
	else:
		raise Exception("Database %s already exists" % (db_name,))

	dbman.create_user(db_name, frappe.conf.db_password)
	if verbose: print "Created user %s" % db_name

	dbman.create_database(db_name)
	if verbose: print "Created database %s" % db_name

	dbman.grant_all_privileges(db_name, db_name)
	dbman.flush_privileges()
	if verbose: print "Granted privileges to user %s and database %s" % (db_name, db_name)

	# close root connection
	frappe.db.close()
开发者ID:gangadhar-kadam,项目名称:laganfrappe,代码行数:30,代码来源:installer.py

示例2: install_db

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import create_database [as 别名]
def install_db(root_login="root", root_password=None, db_name=None, source_sql=None,
	admin_password=None, verbose=True, force=0, site_config=None, reinstall=False):
	make_conf(db_name, site_config=site_config)
	frappe.flags.in_install_db = True
	if reinstall:
		frappe.connect(db_name=db_name)
		dbman = DbManager(frappe.local.db)
		dbman.create_database(db_name)

	else:
		frappe.local.db = get_root_connection(root_login, root_password)
		frappe.local.session = frappe._dict({'user':'Administrator'})
		create_database_and_user(force, verbose)

	frappe.conf.admin_password = frappe.conf.admin_password or admin_password

	frappe.connect(db_name=db_name)
	check_if_ready_for_barracuda()
	import_db_from_sql(source_sql, verbose)
	remove_missing_apps()

	create_auth_table()
	create_list_settings_table()

	frappe.flags.in_install_db = False
开发者ID:drukhil,项目名称:frappe,代码行数:27,代码来源:installer.py

示例3: install_db

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import create_database [as 别名]
def install_db(root_login="root", root_password=None, db_name=None, source_sql=None,
	admin_password = 'admin', verbose=True, force=0, site_config=None, reinstall=False):
	frappe.flags.in_install_db = True
	db_name=db_name[:16]
	if "." in db_name: 
		dn=db_name.split('.')
		db_name=dn[0]
	frappe.errprint(db_name)
	make_conf(db_name, site_config=site_config)
	if reinstall:
		frappe.connect(db_name=db_name)
		dbman = DbManager(frappe.local.db)
		dbman.create_database(db_name)

	else:
		frappe.local.db = make_connection(root_login, root_password)
		frappe.local.session = frappe._dict({'user':'Administrator'})
		create_database_and_user(force, verbose)

	frappe.conf.admin_password = admin_password

	frappe.connect(db_name=db_name)
	import_db_from_sql(source_sql, verbose)

	create_auth_table()
	frappe.flags.in_install_db = False
开发者ID:gangadhar-kadam,项目名称:laganfrappe,代码行数:28,代码来源:installer.py

示例4: install_db

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import create_database [as 别名]
def install_db(root_login="root", root_password=None, db_name=None, source_sql=None,
	admin_password=None, verbose=True, force=0, site_config=None, reinstall=False):
	make_conf(db_name, site_config=site_config)
	frappe.flags.in_install_db = True
	if reinstall:
		frappe.connect(db_name=db_name)
		dbman = DbManager(frappe.local.db)
		dbman.create_database(db_name)

	else:
		frappe.local.db = get_root_connection(root_login, root_password)
		frappe.local.session = frappe._dict({'user':'Administrator'})
		create_database_and_user(force, verbose)

	frappe.conf.admin_password = frappe.conf.admin_password or admin_password

	frappe.connect(db_name=db_name)
	check_if_ready_for_barracuda()
	import_db_from_sql(source_sql, verbose)
	if not 'tabDefaultValue' in frappe.db.get_tables():
		print('''Database not installed, this can due to lack of permission, or that the database name exists.
Check your mysql root password, or use --force to reinstall''')
		sys.exit(1)

	remove_missing_apps()

	create_auth_table()
	setup_global_search_table()
	create_user_settings_table()

	frappe.flags.in_install_db = False
开发者ID:ESS-LLP,项目名称:frappe,代码行数:33,代码来源:installer.py

示例5: make_database

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import create_database [as 别名]
	def make_database(self):
		dbman = DbManager(get_root_connection())

		# make database
		if not help_db_name in dbman.get_database_list():
			dbman.create_user(help_db_name, help_db_name)
			dbman.create_database(help_db_name)
			dbman.grant_all_privileges(help_db_name, help_db_name)
			dbman.flush_privileges()
开发者ID:MostafaBalata,项目名称:frappe,代码行数:11,代码来源:help.py

示例6: make_database

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import create_database [as 别名]
	def make_database(self):
		'''make database for global help setup'''
		if not self.global_help_setup:
			return

		dbman = DbManager(get_root_connection())
		dbman.drop_database(self.help_db_name)

		# make database
		if not self.help_db_name in dbman.get_database_list():
			try:
				dbman.create_user(self.help_db_name, self.help_db_name)
			except Exception as e:
				# user already exists
				if e.args[0] != 1396: raise
			dbman.create_database(self.help_db_name)
			dbman.grant_all_privileges(self.help_db_name, self.help_db_name)
			dbman.flush_privileges()
开发者ID:JiShangShiDai,项目名称:frappe,代码行数:20,代码来源:help.py

示例7: create_database_and_user

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import create_database [as 别名]
def create_database_and_user(force, verbose):
	db_name = frappe.local.conf.db_name
	dbman = DbManager(frappe.local.db)
	if force or (db_name not in dbman.get_database_list()):
		dbman.delete_user(db_name, get_current_host())
		dbman.drop_database(db_name)
	else:
		raise Exception("Database %s already exists" % (db_name,))

	dbman.create_user(db_name, frappe.conf.db_password, get_current_host())
	if verbose: print "Created user %s" % db_name

	dbman.create_database(db_name)
	if verbose: print "Created database %s" % db_name

	dbman.grant_all_privileges(db_name, db_name, get_current_host())
	dbman.flush_privileges()
	if verbose: print "Granted privileges to user %s and database %s" % (db_name, db_name)

	# close root connection
	frappe.db.close()
开发者ID:AhmedHamedTN,项目名称:frappe,代码行数:23,代码来源:installer.py


注:本文中的frappe.model.db_schema.DbManager.create_database方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。