Python sqlalchemy 模块,event() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用sqlalchemy.event()

项目:AstroObjectSchema    作者:HackCoolStars    | 项目源码 | 文件源码
def _fk_pragma_on_connect(dbapi_con, connection_record):
    ''' Code to execute every time the database connection is opened.

    Ref: http://docs.sqlalchemy.org/en/rel_0_9/core/event.html#sqlalchemy.event.listens_for
    '''
    # Support for foreign keys must be explicitly turned on
    # every time the database is opened.
    dbapi_con.execute('PRAGMA foreign_keys=ON')

    # Only uncomment these if you know what you are doing.
    # See the SQLite documentation for details.
    #dbapi_con.execute("PRAGMA journal_mode = MEMORY")
    #dbapi_con.execute("PRAGMA synchronous = OFF")
    #dbapi_con.execute("PRAGMA temp_store = MEMORY")
    #dbapi_con.execute("PRAGMA cache_size = 500000")

# This allows the file to be 'import'ed any number of times, but attempts to
# connect to the database only once.
项目:tuning-box    作者:openstack    | 项目源码 | 文件源码
def fix_sqlite():
    engine = db.engine

    @sqlalchemy.event.listens_for(engine, "connect")
    def _connect(dbapi_connection, connection_record):
        dbapi_connection.isolation_level = None

    @sqlalchemy.event.listens_for(engine, "begin")
    def _begin(conn):
        conn.execute("BEGIN")
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def _include_sqlalchemy(obj):
    for module in sqlalchemy, sqlalchemy.orm:
        for key in module.__all__:
            if not hasattr(obj, key):
                setattr(obj, key, getattr(module, key))
    # Note: obj.Table does not attempt to be a SQLAlchemy Table class.
    obj.Table = _make_table(obj)
    obj.relationship = _wrap_with_default_query_class(obj.relationship)
    obj.relation = _wrap_with_default_query_class(obj.relation)
    obj.dynamic_loader = _wrap_with_default_query_class(obj.dynamic_loader)
    obj.event = event
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def _include_sqlalchemy(obj):
    for module in sqlalchemy, sqlalchemy.orm:
        for key in module.__all__:
            if not hasattr(obj, key):
                setattr(obj, key, getattr(module, key))
    # Note: obj.Table does not attempt to be a SQLAlchemy Table class.
    obj.Table = _make_table(obj)
    obj.relationship = _wrap_with_default_query_class(obj.relationship)
    obj.relation = _wrap_with_default_query_class(obj.relation)
    obj.dynamic_loader = _wrap_with_default_query_class(obj.dynamic_loader)
    obj.event = event
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def _include_sqlalchemy(obj):
    for module in sqlalchemy, sqlalchemy.orm:
        for key in module.__all__:
            if not hasattr(obj, key):
                setattr(obj, key, getattr(module, key))
    # Note: obj.Table does not attempt to be a SQLAlchemy Table class.
    obj.Table = _make_table(obj)
    obj.relationship = _wrap_with_default_query_class(obj.relationship)
    obj.relation = _wrap_with_default_query_class(obj.relation)
    obj.dynamic_loader = _wrap_with_default_query_class(obj.dynamic_loader)
    obj.event = event
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def _include_sqlalchemy(obj):
    for module in sqlalchemy, sqlalchemy.orm:
        for key in module.__all__:
            if not hasattr(obj, key):
                setattr(obj, key, getattr(module, key))
    # Note: obj.Table does not attempt to be a SQLAlchemy Table class.
    obj.Table = _make_table(obj)
    obj.relationship = _wrap_with_default_query_class(obj.relationship)
    obj.relation = _wrap_with_default_query_class(obj.relation)
    obj.dynamic_loader = _wrap_with_default_query_class(obj.dynamic_loader)
    obj.event = event