On Aug 11, 2007, at 9:30 PM, Andy Hird wrote:

>
>>
>> just place the "primary_key=True" attribute on your Column.  since
>> its an existing table in your oracle database, you arent creating the
>> table there so nothing changes.
>
> Ah yeah. That works. Obviously I lose the foreign key relationship
> with account_ids which is a bit of a shame.

whys that  ?  theres no reason you can't set both on the column.

>
> It'd be quite useful, certainly for people like me working with large
> lumbersome legacy databases, if you could specify a non-primary key
> column to use for doing things like updates.

but...the column *is* a primary key column - it identifies the row  
uniquely.  has nothing to do with what the oracle database thinks it  
is, its just a flag you put on the column.

there is also a "primary_key" argument you can specify on the mapper  
directly, which is a list of primary key columns.  but in your case  
it makes your mapping more cumbersome, as if you said "primary_key= 
[table1.c.id, table2.c.id]", then youd have to identify instances as  
(1, 1) instead of just "1".  when the primary key flags are on the  
Table, the mapper can figure out that they are both the "same" value  
since they are also linked by a foreign key constraint.

> I haven't looked too deep
> into the sqlalchemy code but is that something that'd be theoretically
> possible to code. i.e. Something similar to adding a primary_key =
> True attribute, maybe having a use_as_key=True attribute on some non
> primary key column (but preserving foreign key relations for example)?

whats the difference ?  are we just talking about decoupling create()  
from the definition of the Table ?  if controlling create() is the  
issue, its a lot more flexible to just create two Table objects, one  
for your DDL and one for your mappers.




--~--~---------~--~----~------------~-------~--~----~
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