Last active
May 1, 2018 14:44
-
-
Save ssomnoremac/22d9c32fafe50f043b4234ffbf1da925 to your computer and use it in GitHub Desktop.
database connection for graphene using sqlalchemy
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
from sqlalchemy import create_engine | |
from sqlalchemy.ext.declarative import declarative_base, DeferredReflection | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
connection_string = << your connection string here >> | |
engine = create_engine(connection_string) | |
db_session = scoped_session(sessionmaker(autocommit=False, | |
autoflush=False, | |
bind=engine)) | |
Base = declarative_base(cls=DeferredReflection) | |
Base.query = db_session.query_property() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment