本文整理汇总了Python中pyramid_sqlalchemy.Session.connection方法的典型用法代码示例。如果您正苦于以下问题:Python Session.connection方法的具体用法?Python Session.connection怎么用?Python Session.connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid_sqlalchemy.Session
的用法示例。
在下文中一共展示了Session.connection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: includeme
# 需要导入模块: from pyramid_sqlalchemy import Session [as 别名]
# 或者: from pyramid_sqlalchemy.Session import connection [as 别名]
def includeme(config):
config.add_jinja2_search_path("templates")
config.include('pyramid_sacrud', route_prefix='/admin')
settings = config.registry.settings
conn = DBSession.connection()
dialect = conn.dialect.name.lower()
settings['pyramid_sacrud.models'] = get_sacrud_models(dialect)
示例2: includeme
# 需要导入模块: from pyramid_sqlalchemy import Session [as 别名]
# 或者: from pyramid_sqlalchemy.Session import connection [as 别名]
def includeme(config):
settings = config.registry.settings
# init Postgres
engine = DBSession.bind.engine
conn = DBSession.connection()
dialect = conn.dialect.name.lower()
if dialect == 'postgresql':
from psycopg2.extras import register_hstore
initializedb.add_extension(engine, 'hstore')
register_hstore(engine.raw_connection(), True)
# initializedb
if settings.get('sacrud.debug_reload_database', False):
initializedb.main(argv=["init", settings['ini_file']])