Skip to content

Instantly share code, notes, and snippets.

@devoto13
Created November 24, 2015 11:22
Show Gist options
  • Save devoto13/534cdcc6bfd77b29ba9c to your computer and use it in GitHub Desktop.
Save devoto13/534cdcc6bfd77b29ba9c to your computer and use it in GitHub Desktop.
SQLAlchemy boilerplate for experiments
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