Created
May 6, 2013 12:45
-
-
Save Drvanon/5524876 to your computer and use it in GitHub Desktop.
Sqlalchemy template, because I hate repeating myself
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, Column, Integer, String # , ForeignKey | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import sessionmaker # , relationship, backref | |
engine = create_engine('sqlite://:memory:') | |
Base = declarative_base() | |
# Table classes here | |
# example: | |
# class Reaction(Base): | |
# __tablename__ = 'reactions' | |
# | |
# id = Column(Integer, primary_key=True) | |
# content = Column(String) | |
# | |
# def __init__(self, content): | |
# self.content = content | |
# | |
# def __repr__(self): | |
# return '<Reaction {0}'.format(self.content[:5] | |
Base.metadata.create_all(engine) | |
Session = sessionmaker(bind=engine) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment