本文整理汇总了Python中mediadrop.model.meta.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediadrop.model.meta.DBSession
的用法示例。
在下文中一共展示了DBSession.configure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_model
# 需要导入模块: from mediadrop.model.meta import DBSession [as 别名]
# 或者: from mediadrop.model.meta.DBSession import configure [as 别名]
def init_model(engine, table_prefix=None):
"""Call me before using any of the tables or classes in the model."""
DBSession.configure(bind=engine)
from mediadrop.model import meta
meta.metadata.bind = engine
meta.engine = engine
# Change all table names to include the given prefix. This can't be
# easily done before the models are added to the metadata because
# that happens on import, before the config is available.
if table_prefix:
table_prefix = table_prefix.rstrip('_') + '_'
for table in meta.metadata.sorted_tables:
table.name = table_prefix + table.name