当前位置: 首页>>代码示例>>Python>>正文


Python DBSESSION.configure方法代码示例

本文整理汇总了Python中autonomie_base.models.base.DBSESSION.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSESSION.configure方法的具体用法?Python DBSESSION.configure怎么用?Python DBSESSION.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在autonomie_base.models.base.DBSESSION的用法示例。


在下文中一共展示了DBSESSION.configure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connection

# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import configure [as 别名]
def connection(request, settings):
    """ sets up a SQLAlchemy engine and returns a connection
        to the database.

        :param settings: the settings of the test (given by the testing fixture)
        :returns: a sqlalchemy connection object
    """
    # the following setup is based on `kotti.resources.initialize_sql`,
    # except that it explicitly binds the session to a specific connection
    # enabling us to use savepoints independent from the orm, thus allowing
    # to `rollback` after using `transaction.commit`...
    initialize_test_database(settings)

    from autonomie_base.models.base import DBSESSION, DBBASE
    engine = engine_from_config(settings, prefix='sqlalchemy.')
    _connection = engine.connect()
    DBSESSION.registry.clear()
    DBSESSION.configure(bind=_connection)
    DBBASE.metadata.bind = engine

    def drop_db():
        """
            drop the test database
        """
        print("DROPPING DB")
        if __current_test_ini_file().endswith('travis.ini'):
            return
        db_settings = get_test_options_from_settings(settings)
        launch_cmd(db_settings['drop'])

    request.addfinalizer(drop_db)
    return _connection
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:34,代码来源:conftest.py


注:本文中的autonomie_base.models.base.DBSESSION.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。