I doubt this is possible, but SqlAlchemy supports so many oddities it might 
be...

I have an association class/table which has a primary key on the serial 
column `id`, and a unique constraint on the columns `id_a` and `id_b` which 
acts as a secondary key.  

is there a sane way to use something like `.get()` against the `(id_a, 
id_b)` tuple, as if it were the primary key?  i.e. return a matching record 
if it is in the session, otherwise perform a database fetch.

I'm dealing with a path of logic in which this object might be loaded by 
the tuple 5 times, and would like to eliminate the redundant queries, as 
this happens on a highly trafficked view on a webapp.

I've considered using a secondary class mapped to the same table, using the 
tuple as the primary key.  

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to