Michael Bayer wrote: from sqlalchemy import * from sqlalchemy.orm import mapper
from dvzrv.db import sAmetaData class SrvDomainTable(object): def __init__(self,domain_name=None,srv_id=None): self.sAtablename = 'srv_domain' self.sAsrv_domain_table = Table(self.sAtablename, sAmetaData,autoload=True) self.sAmapped_srv_domain = mapper(SrvDomainTable,self.sAsrv_domain_table,primary_key=[self.sAsrv_domain_table.c.domain_name]) > its not going to work if you create the mapper() (and Table) per class > instance (i.e. within __init__), It was a typo. It should be all SrvDomainTable. But why shouldn't it work, I already do the test and it does. Could you please be more specific about this ? >> [self.sAsrv_domain_table.c.domain_name,self.sAsrv_domain_table.c.srv_id]. > assuming you are creating a Mapper to an association table, yes its > typical that the FK columns which connect the two target classes > formulate the primary key for the purposes of mapping (i.e. it > uniquely identifies the row). So this is the intended way to map a table which only connects to tables with the usage of FKs ? > this is not what SQLA refers to as an "association mapping", this is > just a many-to-many which is somethign different. It could be that I misunderstand the intention of SA in relation to association mapping. What I want, is to map the association table (the table which connects two tables, that has only 2 keys - the foreign keys) to an object the same as i do with the rest of the tables; which all have nomrally an *explicit* pk. As I run into an error in relation of a missing pk, I tried to cope with that.In addition I found some post (anywhere), which handled this with adding this primary_key=[]-thing for those classes. So because I have not used SA before, there might be some gaps of understanding ;-) greetings gregor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---