Is it better to reflect and map the tables in the meta.py file or just
create the engine, meta data, and the session in the meta file and
have each model file reflect and map its respective table? An example
of the latter follows:
# meta.py
from sqlalchemy import schema, engine, orm
pg_db = engine.create_engine("postgres://
postgres:[email protected]:5432/sample")
meta_data = schema.MetaData()
meta_data.bind = pg_db
unscoped_session = orm.sessionmaker(bind=pg_db, autoflush=True,
autocommit=False, expire_on_commit=True)
session = orm.scoped_session(unscoped_session)
# end meta.py
# books_model.py
from sqlalchemy import schema, orm
from helloworld.model import meta
books_tbl = schema.Table("books", meta.meta_data, autoload=True)
class Books(object):
pass
orm.mapper(Books, books_tbl)
# end books_model.py
Best,
Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---