Hello,
How do I go from class like defeinition to below with mapper.
The docs in 0.8 say I can use:
from sqlalchemy.ext.declarative import DeferredReflectionBase =
declarative_base()
class MyClass(DeferredReflection, Base):
__tablename__ = 'mytable'
but how do I do below with DefferedReflection
------
from sqlalchemy import Table
from sqlalchemy.orm import mapper, relation
class Recall(object):
def __init__(self, **kw):
"""automatically mapping attributes"""
for key, value in kw.iteritems():
setattr(self, key, value)
recall_table = Table('recall_db', metadata,
autoload=True,autoload_with=engine)
mapper(Recall, recall_table,primary_key=[recall_table.c.RECORD_ID])
----
I'm using pyramid, and I want to autoload tables in models.py which does
not have the engine bound yet. I will bind in in main function with
DeferredReflection.prepare(engine)
Thanks
Lucas
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.