Specify a relation in a mapper. Look at the examples in the ORM tutorial part of the documentation.
assuming you have already defined the tables: mapper (Profile, profiles_table, properties={ 'skills':relation(skills_table, backref='user')}) This will give you a list of skills related to a profile, and each skill related to a user. -- Mike Conley On Sat, Aug 15, 2009 at 5:19 PM, Sid <crulshor...@gmail.com> wrote: > > Hi, > > I'm new to SQLAlchemy and ORMs in general so I have a couple of > questions. > > Basically I have a class called Profile that contains the following > members: > > class Profile: > def __init__(self): > self.user_id = none > self.first_name = none > self.last_name = none > self.email = none > self.birth_date = none > self.skills = () > > The skills data attribute is just a tuple of strings. The following is > the database structure I was planning to use: > > Profiles Table > > | user_id | first_name | last_name | email | birth_date | > > Skills Table > > | skill_id | skill | user_id | > > So the Skills table has a foreign key called user_id which defines > what user that skill belongs to. > > Now, I was looking through the documentation and the best way I found > to map multiple tables to one class was to use the join keyword. Is > this the method I should use? > > Also, I'm wondering can ORMs map lists/tuples/dictionaries to one > column in a table? So, for example in this case the Profiles table > would just have an extra column called skills and I no longer would > need a separate table to store skills as I do currently? I don't think > this is possible but I thought I'd just ask to be sure. > > Thanks, > > Sid > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---