[sqlalchemy] Re: getting data from primary keys
That did the trick. Thanks a lot. Your solution uses the orm sessionmaker. Till now my script was relying on sqlalchemy's expression language. Is there some way of doing the same with the expression language? Or would it get too complicated? (Just curious) Cheers, T On Mon, Sep 14, 2009 at 5:02 PM, Mike Conley mconl...@gmail.com wrote: If I understand this, you want to construct a query that returns the primary keys in an arbitrary table? Try this: key_cols = [c for c in table.primary_key.columns] session.query(*key_cols).all() -- Todd Matsumoto --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: getting data from primary keys
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of C.T. Matsumoto Sent: 15 September 2009 07:21 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: getting data from primary keys That did the trick. Thanks a lot. Your solution uses the orm sessionmaker. Till now my script was relying on sqlalchemy's expression language. Is there some way of doing the same with the expression language? Or would it get too complicated? (Just curious) Cheers, T How about: import sqlalchemy as sa key_cols = [c for c in table.primary_key.columns] query = sa.select(key_cols) print query.execute().fetchall() Or print connection.execute(query).fetchall() Hope that helps, Simon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: getting data from primary keys
Thanks for the help! T On Tue, Sep 15, 2009 at 12:33 PM, King Simon-NFHD78 simon.k...@motorola.com wrote: -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of C.T. Matsumoto Sent: 15 September 2009 07:21 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: getting data from primary keys That did the trick. Thanks a lot. Your solution uses the orm sessionmaker. Till now my script was relying on sqlalchemy's expression language. Is there some way of doing the same with the expression language? Or would it get too complicated? (Just curious) Cheers, T How about: import sqlalchemy as sa key_cols = [c for c in table.primary_key.columns] query = sa.select(key_cols) print query.execute().fetchall() Or print connection.execute(query).fetchall() Hope that helps, Simon -- Todd Matsumoto --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: getting data from primary keys
If I understand this, you want to construct a query that returns the primary keys in an arbitrary table? Try this: key_cols = [c for c in table.primary_key.columns] session.query(*key_cols).all() --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---