from sqlalchemy import create_enginefrom sqlalchemy.orm import sessionmakerengine = create_engine('postgresql+psycopg2://USER:PASSWORD@127.0.0.1:5432/DB_OR_TEMPLATE')session = sessionmaker(bind=engine)()session.connection().connection.set_isolation_level(0)session.execute('CREATE DATAbase test')session.connection().connection.set_isolation_level(1)
如果您没有任何数据库,则应使用
template1
"""Isolation level values."""ISOLATION_LEVEL_AUTOCOMMIT = 0ISOLATION_LEVEL_READ_COMMITTED = 1ISOLATION_LEVEL_SERIALIZABLE = 2
http://initd.org/psycopg/docs/connection.html#connection.set_isolation_level
http://initd.org/psycopg/docs/extensions.html#isolation-level-
constants
http://www.postgresql.org/docs/current/static/transaction-
iso.html
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)