Karl Guertin wrote: > On 1/31/06, Michael Bayer <[EMAIL PROTECTED]> wrote: > >>m = mapper(myclass, table, primary_key=[table.c.asn, table.c.type]) >> >>Which just tells the mapper what cols make up the primary key. > > > Thanks for the response. Unfortunately, I don't completely understand > the implications of 'make up the primary key'. > > What are the limitations on primary keys? Do primary keys need to be > immutable? Does the primary key (explicit or composite) need to have a > 1:1 mapping onto rows or can the pk map to multiple rows? If the > latter is the case, how are updates handled? > > I'd guess that result rows are directly turned into mapped class > instances, but updates and deletes would apply to all rows addressed > by the pk. I should probably figure this out by looking at code, but > clarification would be appreciated. > >
Karl, I think your questions are actually about SQL in general, not SqlAlchemy in particular. The definition of a primary key is "a column or set of columns that uniquely specifies a row". So if you update or delete based on a primary key, you will affect zero or one rows, never more. Each column of the database will only contain a string or a number, not any kind of fancier Python object, so any object you can put in your db will be immutable. It might be a pickle of a Python object, but as far as the db is concerned that's a string. -- Wade Leftwich Ithaca, NY ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ Sqlalchemy-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

