本文整理匯總了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: