Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SQLAlchemy Session from DBAPI Connection
def session_from_connection(conn):
def passthrough_conn():
return conn
# note that the url here doesn't matter, but it has to parse correctly as a url
engine = create_engine('postgresql://foo@bar/abc', creator=passthrough_conn)
session = Session(bind=engine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment