Created
April 18, 2017 01:11
-
-
Save szastupov/e74213a3def0afa26caa7c0c92c6b2f6 to your computer and use it in GitHub Desktop.
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
import sqlalchemy as sa | |
from sqlalchemy.ext.declarative import as_declarative, declared_attr | |
from sqlalchemy.orm import relationship, sessionmaker | |
engine = sa.create_engine('sqlite://') | |
Session = sessionmaker(bind=engine) | |
@as_declarative() | |
class Base(object): | |
@declared_attr | |
def __tablename__(cls): | |
return cls.__name__.lower() + 's' | |
id = sa.Column(sa.Integer, primary_key=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment