I'm new to pylons and I'm trying to use reflection to autoload my app
tables. I'm afraid that I've gotten my files munged up pretty badly at
this point but I've tried everything I can think of. I use these
constructs all the time with sqlalchemy outside of pylons.
I need to bind the engine to meta data and get to it in my model files
(one for each table) or get directly to the engine object. I can't
figure out how to do either.
My model file is account.py:
from meta import metadata
from sqlalchemy import Table
accounts_table = Table('accounts',metadata, autoload=True,
autoload_with=metadata.engine)
class Accounts(object):
pass
meta.orm.mapper(Accounts,accounts_table,primary_key=[accounts_table.c.acct_id])
==========================================
My meta.py is:from sqlalchemy import MetaData
from sqlalchemy.orm import scoped_session, sessionmaker
__all__ = ['Session', 'metadata']
Session = scoped_session(sessionmaker())
metadata = MetaData()
==========================================
and my __init__.py is:"""The application's model objects"""
from sqlalchemy import orm
from sqlalchemy.orm import sessionmaker, scoped_session
from accounts.model import meta
def init_model(engine):
Session.configure(bind=engine)
meta.metadata.bind = engine
meta.engine = engine
Thanks in advance
--
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.