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)