On Aug 27, 2014, at 6:17 PM, Gerald Thibault <dieselmach...@gmail.com> wrote:

> I have a pretty simple goal, so simple I probably don't even need example 
> code.
> 
> I have 2 classes, and I want to pull the identity key from an instance of one 
> class, and use the values to create an instance of the second, without 
> requiring (or introspecting) things like the PK names, FK names linking them, 
> etc. Something like:
> 
> instance1 = Class1()
> cls, vals = identity_key(instance=instance1)
> instance2 = Class2.from_identity_key(vals) # that method doesn't exist
> 
> I am trying to do this without requiring any of the PK column names or FK 
> info linking the 2 tables together (they are a 1-to-1 relationship). given 
> only an instance of Class1 and the class "Class2", I want to create the 
> instance of Class2.
> 
> Is this possible? Is there a way to "reverse" identity_key, so instead of 
> instance -> (cls, vals)  I could do (cls, vals) -> instance?

OK well how to the primary key attributes of Class1 and Class2 relate?   If 
Class1's primary key columns are "a", "b", and Class2's primary key columns 
are, "id", how is that mapping done?  are we assuming same number of columns in 
the PK of both, in the same order, or same names, or what?


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to