1 """The application's model objects"""
2 import sqlalchemy as sa
3 from sqlalchemy import orm
5 from bluechips.model import meta
7 def init_model(engine):
8 """Call me before using any of the tables or classes in the model"""
9 ## Reflected tables must be defined and mapped here
10 #global reflected_table
11 #reflected_table = sa.Table("Reflected", meta.metadata, autoload=True,
12 # autoload_with=engine)
13 #orm.mapper(Reflected, reflected_table)
15 sm = orm.sessionmaker(autoflush=True, transactional=True, bind=engine)
18 meta.Session = orm.scoped_session(sm)
21 ## Non-reflected tables may be defined and mapped at module level
22 #foo_table = sa.Table("Foo", meta.metadata,
23 # sa.Column("id", sa.types.Integer, primary_key=True),
24 # sa.Column("bar", sa.types.String(255), nullable=False),
30 #orm.mapper(Foo, foo_table)
33 ## Classes for reflected tables may be defined here, but the table and
34 ## mapping itself must be done in the init_model function
35 #reflected_table = None
37 #class Reflected(object):