Jan Dittberner
554276ed23
git-svn-id: file:///var/www/wwwusers/usr01/svn/pyalchemybiz/trunk@5 389c73d4-bf09-4d3d-a15e-f94a37d0667a
18 lines
565 B
Python
18 lines
565 B
Python
import sqlalchemy as sa
|
|
from sqlalchemy import orm
|
|
|
|
from pyalchemybiz.model import meta
|
|
from pyalchemybiz.model import customer
|
|
|
|
def init_model(engine):
|
|
"""Call me before using any of the tables or classes in the model."""
|
|
|
|
sm = orm.sessionmaker(autoflush=True, transactional=True, bind=engine)
|
|
|
|
meta.engine = engine
|
|
meta.Session = orm.scoped_session(sm)
|
|
|
|
customer.t_customer = sa.Table('customer', meta.metadata,
|
|
autoload=True, autoload_with=engine)
|
|
orm.mapper(customer.Customer, customer.t_customer)
|