Hello everybody,
I'm wondering if there is a "standard" way of doing something like the
following:
masters = Table('masters', meta,
Column('id', Integer, primary_key=True),
Column('name', String, unique, nullable=False)
)
details = Table('details', meta,
Column('id', Integer, primary_key=True),
Column('master_id', Integer, ForeignKey('masters.id'),
nullable=False),
Column('name', String, nullable=False),
UniqueConstraint('master_id', 'name')
)
class Master(object): pass
mapper(Master, masters, properties={'details': relation(Detail)})
class Detail(object):
def __init__(self, master_name, name):
'''Magic happens here
assigning to master_name forces master_id to be magically resolved
later on, probably by MapperExtension
'''
self.master_name = master_name
self.name = name
mapper(Detail, details, properties={'master': relation(Master)})
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---