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


Python DbManager.delete_user方法代码示例

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


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

示例1: create_database_and_user

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import delete_user [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: drop_site

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import delete_user [as 别名]
def drop_site(site, root_login='root', root_password=None):
	from frappe.installer import get_current_host, make_connection
	from frappe.model.db_schema import DbManager
	from frappe.utils.backups import scheduled_backup

	frappe.init(site=site)
	frappe.connect()
	scheduled_backup(ignore_files=False, force=True)

	db_name = frappe.local.conf.db_name
	frappe.local.db = make_connection(root_login, root_password)
	dbman = DbManager(frappe.local.db)
	dbman.delete_user(db_name, get_current_host())
	dbman.drop_database(db_name)

	archived_sites_dir = os.path.join(frappe.get_app_path('frappe'), '..', '..', '..', 'archived_sites')
	if not os.path.exists(archived_sites_dir):
		os.mkdir(archived_sites_dir)
	move(archived_sites_dir, site)
开发者ID:shitolepriya,项目名称:saloon_offline_frappe,代码行数:21,代码来源:commands.py

示例3: create_database_and_user

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import delete_user [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

示例4: _drop_site

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import delete_user [as 别名]
def _drop_site(site, root_login='root', root_password=None, archived_sites_path=None, force=False):
	"Remove site from database and filesystem"
	from frappe.installer import get_root_connection
	from frappe.model.db_schema import DbManager
	from frappe.utils.backups import scheduled_backup

	frappe.init(site=site)
	frappe.connect()

	try:
		scheduled_backup(ignore_files=False, force=True)
	except SQLError as err:
		if err[0] == ER.NO_SUCH_TABLE:
			if force:
				pass
			else:
				click.echo("="*80)
				click.echo("Error: The operation has stopped because backup of {s}'s database failed.".format(s=site))
				click.echo("Reason: {reason}{sep}".format(reason=err[1], sep="\n"))
				click.echo("Fix the issue and try again.")
				click.echo(
					"Hint: Use 'bench drop-site {s} --force' to force the removal of {s}".format(sep="\n", tab="\t", s=site)
				)
				sys.exit(1)

	db_name = frappe.local.conf.db_name
	frappe.local.db = get_root_connection(root_login, root_password)
	dbman = DbManager(frappe.local.db)
	dbman.delete_user(db_name)
	dbman.drop_database(db_name)

	if not archived_sites_path:
		archived_sites_path = os.path.join(frappe.get_app_path('frappe'), '..', '..', '..', 'archived_sites')

	if not os.path.exists(archived_sites_path):
		os.mkdir(archived_sites_path)

	move(archived_sites_path, site)
开发者ID:JiShangShiDai,项目名称:frappe,代码行数:40,代码来源:site.py

示例5: drop_site

# 需要导入模块: from frappe.model.db_schema import DbManager [as 别名]
# 或者: from frappe.model.db_schema.DbManager import delete_user [as 别名]
def drop_site(site, root_login='root', root_password=None, archived_sites_path=None):
	"Remove site from database and filesystem"
	from frappe.installer import get_root_connection
	from frappe.model.db_schema import DbManager
	from frappe.utils.backups import scheduled_backup

	frappe.init(site=site)
	frappe.connect()
	scheduled_backup(ignore_files=False, force=True)

	db_name = frappe.local.conf.db_name
	frappe.local.db = get_root_connection(root_login, root_password)
	dbman = DbManager(frappe.local.db)
	dbman.delete_user(db_name)
	dbman.drop_database(db_name)

	if not archived_sites_path:
		archived_sites_path = os.path.join(frappe.get_app_path('frappe'), '..', '..', '..', 'archived_sites')

	if not os.path.exists(archived_sites_path):
		os.mkdir(archived_sites_path)

	move(archived_sites_path, site)
开发者ID:ckosiegbu,项目名称:frappe,代码行数:25,代码来源:site.py


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