本文整理汇总了Python中mediagoblin.db.base.Session.configure方法的典型用法代码示例。如果您正苦于以下问题:Python Session.configure方法的具体用法?Python Session.configure怎么用?Python Session.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediagoblin.db.base.Session
的用法示例。
在下文中一共展示了Session.configure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_connection_and_db_from_config
# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import configure [as 别名]
def setup_connection_and_db_from_config(app_config, migrations=False, app=None):
engine = create_engine(app_config['sql_engine'])
# @@: Maybe make a weak-ref so an engine can get garbage
# collected? Not that we expect to make a lot of MediaGoblinApp
# instances in a single process...
engine.app = app
# Enable foreign key checking for sqlite
if app_config['sql_engine'].startswith('sqlite://'):
if migrations:
event.listen(engine, 'connect',
_sqlite_disable_fk_pragma_on_connect)
else:
event.listen(engine, 'connect', _sqlite_fk_pragma_on_connect)
# logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
if DISABLE_GLOBALS:
return DatabaseManager(engine)
else:
Session.configure(bind=engine)
return DatabaseMaster(engine)
示例2: setup_connection_and_db_from_config
# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import configure [as 别名]
def setup_connection_and_db_from_config(app_config, migrations=False):
engine = create_engine(app_config['sql_engine'])
# Enable foreign key checking for sqlite
if app_config['sql_engine'].startswith('sqlite://'):
if migrations:
event.listen(engine, 'connect',
_sqlite_disable_fk_pragma_on_connect)
else:
event.listen(engine, 'connect', _sqlite_fk_pragma_on_connect)
# logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
Session.configure(bind=engine)
return DatabaseMaster(engine)
示例3: setup_connection_and_db_from_config
# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import configure [as 别名]
def setup_connection_and_db_from_config(app_config):
engine = create_engine(app_config['sql_engine'])
# logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
Session.configure(bind=engine)
return DatabaseMaster(engine)