Created
November 24, 2015 11:22
-
-
Save devoto13/534cdcc6bfd77b29ba9c to your computer and use it in GitHub Desktop.
SQLAlchemy boilerplate for experiments
This file contains hidden or 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 | |
from sqlalchemy.orm import scoped_session | |
from sqlalchemy.orm import sessionmaker | |
Base = declarative_base() | |
# Define models here | |
engine = create_engine('sqlite:///:memory:', echo=True) | |
Base.metadata.create_all(engine) | |
Session = scoped_session(sessionmaker(bind=engine)) | |
if __name__ == '__main__': | |
session = Session() | |
# Derp with SQL here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment