I'm relatively new to sqlalchemy, but am trying to wrap my head around
mappers. They seem pretty intuitive, but I can't see how they handle
normalization. If have a class that has values, which I want to pull
out into other tables, can this be done using just a mapper, or do I
have to check first? I'm running this through sqlite, if that makes a
difference in how to save it.
Like if I insert a mapped Person, I want to add their team name to the
team table and use that primary key as the Person's team value in the
person table. Is this possible, or should I just use inserts?
class Person:
def __init__(self, name, team):
self.name = name
self.team = team
a = Person('Bill', 'Foo')
b = Person('Frank', 'Bar')
c = Person('Jill', 'Foo')
# set up custom mappers and insert a, b, c
...
# data base now looks like this
user|team
---------------------
Bill|0
Frank|1
Jill|0
id|team # id is unique and autoincrements
--------------------
0|Foo
1|Bar
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---