Don't know if this will work in your case.. but to handle joins to so
many static tables.
Note.. I didn't need to update these tables, nor query from them back
to the data tables. (i.e. no need to call Gender.member_profiles())
I did something like the following:
class MemberProfile(Base):
gender_by_desc = make_descriptor_for_static_field(tablename,
id_fieldname, desc_fieldname)('genderID')
with:
def make_descriptor_for_static_field(tablename, id_fieldname,
desc_fieldname)
class C(object):
_cache = None
def __init__(self, data_fieldname):
self.data_fieldname = data_fieldname
t = Table(tablename, metadata, autoload=True)
id_field = getattr(t.c, id_fieldname)
desc_field = getattr(t.c, desc_fieldname)
s = select([id_field, name_field])
result = engine.execute(s)
self._cache = dict(list(result))
def __get__(self, obj, objtype):
v = getattr(obj, self.data_fieldname)
if v is None:
return None
else:
return self._cache[v]
return C
On Feb 4, 6:02 pm, Gloria W <[email protected]> wrote:
> Thanks for this response. I do need all of the data available at once.
>
> Specifically, here is what I'm trying to do. I'm following this
> example right from the docs:
d.
>...
>...
>
> This same example works if I inherit from my Member class, but I don't
> want to do this, since I have to also join Gender, and 40 something
> other tables to this class.
>
> What am I missing to make this work like the example shown?
>
> Thank you immensely,
> Gloria
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---