本文整理汇总了Python中mysql.utilities.common.server.Server.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python Server.disconnect方法的具体用法?Python Server.disconnect怎么用?Python Server.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.utilities.common.server.Server
的用法示例。
在下文中一共展示了Server.disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_audit_log
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import disconnect [as 别名]
def check_audit_log(self):
"""Verify if the audit log plugin is installed on the server.
Return the message error if not, or None.
"""
error = None
server = Server({'conn_info': self.options.get("server_vals", None)})
server.connect()
# Check to see if the plug-in is installed
if not server.supports_plugin("audit"):
error = "The audit log plug-in is not installed on this " + \
"server or is not enabled."
server.disconnect()
return error
示例2: show_options
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import disconnect [as 别名]
def show_options(self):
""" Show all audit log variables.
"""
server = Server({'conn_info': self.options.get("server_vals", None)})
server.connect()
rows = server.show_server_variable("audit%")
server.disconnect()
if rows:
print "#\n# Audit Log Variables and Options\n#"
print_list(sys.stdout, "GRID", ['Variable_name', 'Value'],
rows)
print
else:
raise UtilError("No audit log variables found.")
示例3: do_command
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import disconnect [as 别名]
def do_command(self):
""" Check and execute the audit log command (previously set by the the
options of the object constructor).
"""
# Check for valid command
command = self.options.get("command", None)
if not command in VALID_COMMANDS:
raise UtilError("Invalid command.")
command_value = self.options.get("value", None)
# Check for valid value if needed
if (command_requires_value(command)
and not check_command_value(command, command_value)):
raise UtilError("Please provide the correct value for the %s "
"command." % command)
# Copy command does not need the server
if command == "COPY":
self._copy_log()
return True
# Connect to server
server = Server({'conn_info': self.options.get("server_vals", None)})
server.connect()
# Now execute the command
print "#\n# Executing %s command.\n#\n" % command
try:
if command == "POLICY":
server.exec_query("SET @@GLOBAL.audit_log_policy = %s" %
command_value)
elif command == "ROTATE":
self._rotate_log(server)
else: # "ROTATE_ON_SIZE":
server.exec_query("SET @@GLOBAL.audit_log_rotate_on_size = %s"
% command_value)
finally:
server.disconnect()
return True