hello -

you generally use mapper() and relation() to set up how you'd like
your classes to correspond to your table relationships.  as far as
compound keys, if they are defined with a "primary key" constraint you
shouldn't have to worry about them.

if you need to tell a mapper about some other columns that compose its
"primary key" other than what the actual table has set up as its
primary key, you can use the "primary_key" keyword option on mapper(),
such as mapper(SomeClass, sometable, primary_key=[mytable.c.col1])

As for foreign key relations, these are usually represented at the ORM
level using the relation() function.

the easiest ones are the one-to-many, many-to-one, and many-to-many
relationships, which most of your foreign keys are probably defining.
for 0.3 these are described here:

http://www.sqlalchemy.org/docs/03/datamapping.html#datamapping_relations_onetomany
http://www.sqlalchemy.org/docs/03/datamapping.html#datamapping_morerelations

a more complex relationship is a "self-referential" relationship,
otherwise known as "adjacency list".  use this when a single table
contains a foreign key relationship pointing to itself:

http://www.sqlalchemy.org/docs/03/adv_datamapping.html#advdatamapping_selfreferential

finally, the other common mapping is "inheritance", usually "joined
table inheritance", where a set of rows are referenced by a base
table, but each row also contains additional properties that are added
by one of several joined tables, but only one of those tables for each
parent row:

http://www.sqlalchemy.org/docs/03/adv_datamapping.html#advdatamapping_inheritance_joined

good luck !

- mike


On Aug 16, 11:59 am, "Lukasz Szybalski" <[EMAIL PROTECTED]> wrote:
> Hello,
> I am setting up a website with existing database using turbogears.
> Database is in mysql.
> I am using sqlalchemy but I'm having problems with choosing the mapper?
>
> There is around 20 tables with a lot of foreign key, compound keys and
> alternative keys.
>
> Which mapper do I use?
> Can you point me to the documentation for that as well?
>
> Thanks,
> Lucas


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to