Hi everyone,


I have an database setup where i have two tables/objects that are 
associated via two many to many relationships (with association tables).  I 
would 
like to find a way to quickly query for the existence of one of the 
objects, which is partially defined by its associations with the other 
object.  This is primarily so I can check to see if a given object exists 
before inserting a potential duplicate into my database.  


As an example (AX and BX are objects, [B1, B2, ...] is a list of multiple B 
instances, --X--> denotes a relationship, and X is some number denoting a 
specific object or relationship):


A1 --1--> [B1, B2, B3]

A1 --2--> [B4, B2, B5]

A2 --3--> [B6, B1, B7]

....


Currently I've thought of two (sub-par) solutions: 

1 - Use associations to compute a hash, which is stored in the database and 
used to distinguish the object

2 - Read the whole database into python objects and use those object's 
lists of the other object to compare


I've implemented the first solution and it works, but feels clunky.  Is 
there a better way to do this?  


Thanks!


 - Kovas

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