本文整理汇总了Python中mysql.utilities.common.server.Server.get_all_databases方法的典型用法代码示例。如果您正苦于以下问题:Python Server.get_all_databases方法的具体用法?Python Server.get_all_databases怎么用?Python Server.get_all_databases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.utilities.common.server.Server
的用法示例。
在下文中一共展示了Server.get_all_databases方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Server
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import get_all_databases [as 别名]
print "# Connecting to server..."
server_options = {
'conn_info' : conn,
'role' : "source",
}
server1 = Server(server_options)
try:
server1.connect()
except UtilError, e:
print "ERROR:", e.errmsg
# Get list of databases from the server if not specified in options
print "# Getting databases..."
db_list = []
if opt.dbs_to_copy is None:
for db in server1.get_all_databases():
db_list.append((db[0], None))
else:
for db in opt.dbs_to_copy.split(","):
db_list.append((db, None))
# Get list of all users from the server
print "# Getting users..."
user_list=[]
if opt.users_to_copy is None:
users = server1.exec_query("SELECT user, host "
"FROM mysql.user "
"WHERE user != 'root' and user != ''")
for user in users:
user_list.append(user[0]+'@'+user[1])
else: