Perfect, thank you!

On Mar 23, 10:09 pm, Benjamin Trofatter <bentrofat...@gmail.com>
wrote:
> Not knowing the names of the primary keys shouldn't be a problem since
> they're pretty easy to figure out with the object_mapper.
>
> from sqlalchemy.orm import object_mapper
>
> class MyMixin(object):
>
>     def get_pk(self):
>         om = object_mapper(self)
>         keys = [k.key for k in om.primary_key]
>         return tuple(getattr(self, k) for k in keys)
>
> On Fri, Mar 23, 2012 at 2:48 PM, lars van gemerden 
> <l...@rational-it.com>wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Does anyone know a way get the the value(s) of the primary key(s), if
> > you don't know the name of the primary key column(s). This to be used
> > in a mixin class that can be used for different tables/classes.
>
> > Cheers, Lars
>
> > --
> > 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
> > sqlalchemy+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to