Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

changing isolation level #120

ssfking opened this Issue Mar 20, 2013 · 1 comment


None yet
2 participants

ssfking commented Mar 20, 2013

How do you change the isolation level of a session/transaction without going down to the sqlalchemy layer?

fjbsantiago commented Oct 4, 2016 edited

I don't think it is possible yet. This was the simplest way I found to do it.

from sqlalchemy import create_engine, event

engine = create_engine("sqlite:///myfile.db")

@event.listens_for(engine, "connect")
def do_connect(dbapi_connection, connection_record):
    # disable pysqlite's emitting of the BEGIN statement entirely.
    # also stops it from emitting COMMIT before any DDL.
    dbapi_connection.isolation_level = None

From: http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#serializable-isolation-savepoints-transactional-ddl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment