Created
June 14, 2011 15:59
-
-
Save peterkeen/1025209 to your computer and use it in GitHub Desktop.
SQLAlchemy Session from DBAPI Connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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