本文整理汇总了Python中tornado.options.mysql_host方法的典型用法代码示例。如果您正苦于以下问题:Python options.mysql_host方法的具体用法?Python options.mysql_host怎么用?Python options.mysql_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.options
的用法示例。
在下文中一共展示了options.mysql_host方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import mysql_host [as 别名]
def __init__(self):
handlers = [
(r"/", HomeHandler),
(r"/archive", ArchiveHandler),
(r"/feed", FeedHandler),
(r"/entry/([^/]+)", EntryHandler),
(r"/compose", ComposeHandler),
(r"/auth/create", AuthCreateHandler),
(r"/auth/login", AuthLoginHandler),
(r"/auth/logout", AuthLogoutHandler),
]
settings = dict(
blog_title=u"Tornado Blog",
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
ui_modules={"Entry": EntryModule},
xsrf_cookies=True,
cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
login_url="/auth/login",
debug=True,
)
super(Application, self).__init__(handlers, **settings)
# Have one global connection to the blog DB across all handlers
self.db = torndb.Connection(
host=options.mysql_host, database=options.mysql_database,
user=options.mysql_user, password=options.mysql_password)
self.maybe_create_tables()
示例2: maybe_create_tables
# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import mysql_host [as 别名]
def maybe_create_tables(self):
try:
self.db.get("SELECT COUNT(*) from entries;")
except MySQLdb.ProgrammingError:
subprocess.check_call(['mysql',
'--host=' + options.mysql_host,
'--database=' + options.mysql_database,
'--user=' + options.mysql_user,
'--password=' + options.mysql_password],
stdin=open('schema.sql'))
示例3: __init__
# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import mysql_host [as 别名]
def __init__(self):
handlers = [
(r"/", HomeHandler),
(r"/archive", ArchiveHandler),
(r"/feed", FeedHandler),
(r"/entry/([^/]+)", EntryHandler),
(r"/compose", ComposeHandler),
(r"/auth/login", AuthLoginHandler),
(r"/auth/logout", AuthLogoutHandler),
]
settings = dict(
blog_title=u"Tornado Blog",
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
ui_modules={"Entry": EntryModule},
xsrf_cookies=True,
cookie_secret="11oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
login_url="/auth/login",
autoescape=None,
)
tornado.web.Application.__init__(self, handlers, **settings)
# Have one global connection to the blog DB across all handlers
self.db = tornado.database.Connection(
host=options.mysql_host, database=options.mysql_database,
user=options.mysql_user, password=options.mysql_password)