本文整理汇总了Python中mysql.utilities.common.options.setup_common_options函数的典型用法代码示例。如果您正苦于以下问题:Python setup_common_options函数的具体用法?Python setup_common_options怎么用?Python setup_common_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup_common_options函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_common_options
import time
from mysql.utilities import VERSION_FRM
from mysql.utilities.command.serverinfo import show_server_info
from mysql.utilities.common.options import setup_common_options
from mysql.utilities.common.options import add_format_option
from mysql.utilities.common.options import add_verbosity
from mysql.utilities.exception import UtilError
# Constants
NAME = "MySQL Utilities - mysqlserverinfo "
DESCRIPTION = "mysqlserverinfo - show server information"
USAGE = "%prog --server=user:[email protected]:port:socket --format=grid"
# Setup the command parser and setup server, help
parser = setup_common_options(os.path.basename(sys.argv[0]),
DESCRIPTION, USAGE, True)
# Setup utility-specific options:
# Input format
add_format_option(parser, "display the output in either grid (default), "
"tab, csv, or vertical format", "grid")
# Header row
parser.add_option("-h", "--no-headers", action="store_true", dest="no_headers",
default=False, help="do not show column headers")
# Show my.cnf values
parser.add_option("-d", "--show-defaults", action="store_true",
dest="show_defaults", default=False,
help="show defaults from the config file per server")
示例2: parser
- You can list the users that have specific privileges using the option
--privileges. The user must have all privileges listed in order to be
included in the result.
- If you specify some privileges on the --privileges option that are not
valid for all the specified objects, any that do not apply are not
included in the list. For example, the SELECT privilege will be
ignored for stored routines and the EXECUTE privilege will be ignored for
tables but both will be taken into account for databases.
"""
if __name__ == '__main__':
# Setup the command parser (with common options).
parser = setup_common_options(os.path.basename(sys.argv[0]), DESCRIPTION,
USAGE, append=False, server=True,
server_default=None,
extended_help=EXTENDED_HELP)
# Add verbosity option (no --quite option).
add_verbosity(parser, False)
# Add show mode options
parser.add_option("--show", action="store",
dest="show_mode", type="choice",
default="user_grants",
choices=["users", "user_grants", "raw"],
help="Controls the content of the report. If the value "
"USERS is specified, the report shows only the "
"list of users with any kind of grant over the "
"object. If USER_GRANTS is specified the reports "
"shows each user along with her list of privileges "
示例3: add_pattern
from mysql.utilities.common.options import parse_connection
from mysql.utilities.common.options import setup_common_options
from mysql.utilities.common.options import add_verbosity
from mysql.utilities.common.options import check_format_option
from mysql.utilities.exception import UtilError
def add_pattern(option, opt, value, parser, field):
entry = (field, value)
try:
getattr(parser.values, option.dest).append(entry)
except AttributeError:
setattr(parser.values, option.dest, [entry])
# Setup the command parser and setup server, help
parser = setup_common_options(os.path.basename(sys.argv[0]),
"mysqlprocgrep - search process information",
"%prog --server=user:[email protected]:port:socket "
"[options]", True)
parser.add_option(
"-G", "--basic-regexp", "--regexp",
dest="use_regexp", action="store_true", default=False,
help="Use 'REGEXP' operator to match pattern. Default is to use 'LIKE'.")
parser.add_option(
"-Q", "--print-sql", "--sql",
dest="print_sql", action="store_true", default=False,
help="Print the statement instead of sending it to the server. If a kill option is submitted, a procedure will be generated containing the code for executing the kill.")
parser.add_option(
"--sql-body",
dest="sql_body", action="store_true", default=False,
help="Only print the body of the procedure.")
parser.add_option(
"--kill-connection",
示例4: parser
- The default timeout for performing the table checksum is 5 seconds.
This value can be changed with the --checksum-timeout option.
- The default timeout for waiting for slaves to catch up is 300 seconds.
This value can be changed with the --rpl-timeout option.
- The default interval to periodically verify if a slave has read all of
the GTIDs from the master is 3 seconds. This value can be changed
with the --interval option.
"""
if __name__ == "__main__":
# Setup the command parser (with common options).
parser = setup_common_options(
os.path.basename(sys.argv[0]), DESCRIPTION, USAGE, server=False, extended_help=EXTENDED_HELP
)
# Add the --discover-slaves-login option.
add_discover_slaves_option(parser)
# Add the --master option.
add_master_option(parser)
# Add the --slaves option.
add_slaves_option(parser)
# Add the --ssl options
add_ssl_options(parser)
# Add verbosity option (no --quite option).
示例5: check_python_version
# Check Python version compatibility
check_python_version()
import os.path
import re
import sys
from mysql.utilities.command.grep import ObjectGrep, OBJECT_TYPES
from mysql.utilities.common.options import add_regexp
from mysql.utilities.common.options import setup_common_options
from mysql.utilities.common.options import add_format_option
# Setup the command parser and setup server, help
parser = setup_common_options(
os.path.basename(sys.argv[0]),
"mysqlmetagrep - search metadata",
"%prog --server=user:[email protected]:port:socket " "[options] pattern",
True,
)
# Setup utility-specific options:
parser.add_option(
"-b",
"--body",
dest="check_body",
action="store_true",
default=False,
help="search the body of routines, triggers, and events as well",
)
def quote(string):