Hello,
I am trying to map a legacy schema. There are a few tables that I cannot
figure out how to map. Basically the rows are key-value pairs that
should really be columns in the table (see code examples below). The
rows of the "ideal" table would match the distinct values in the
physical table's first column (username), which would be natural to use
as the primary key.
I would like to know what needs to be done in order to make this kind of
mapping work, so that object add and changes to session would still do
the right thing when flush()ed etc. So far I haven't been able to figure
out exactly how that could be done from the docs, and I am not familiar
enough with the inner workings of SQLAlchemy.
Any advice would be greatly appreciated.
# Real table. Contains rows like:
# 'jsmith', 'realname', 'John Smith'
# 'jsmith', 'address', 'Park Avenue'
# 'jsmith', 'phone', '555-9876'
# 'tkelly', 'realname', 'Tim Kelly'
# etc.
users_table = Table('users', metadata,
Column('username', Unicode, primary_key=True),
Column('attr', Unicode, primary_key=True),
Column('val', Unicode)
)
# Ideal - what I'd like the mapping to "act like"
users_table = Table('users', metadata,
Column('username', Unicode),
Column('realname', Unicode),
Column('address', Unicode)
Column('phone', Unicode)
# etc...
)
Thanks,
--
Teemu Yli-Elsilä
--
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.