Michael,
Thanks for the pointer, that makes great sense, and once again points
how my generally small database design skills. I'll update my code to
try this out.
Again,
Thanks!
Doug
From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of Michael Bayer
Sent:
I keep thinking one of my relatives has emailed me when you post here
and I get all excited. Any chance you can change your name ? :-)
2008/12/2 Doug Farrell [EMAIL PROTECTED]:
Michael,
Thanks for the pointer, that makes great sense, and once again points how my
generally small database
Hi,
If I have an ORM object, it is sometimes convenient to be able to infer
the class directly. Eg. consider this function.
def add_patient_obj(session, patient_obj):
Check if object primary key exists in db. If so,exit, else
add.
pid = patient_obj.id
#print
I could use some insightful suggestions here:
What do you think of this use case?
Let's say I have a class Foo mapped to a table 'foos', and a
many:many relation between these objects, stored in the table
'foo_relations'.
columns on foos:
id (Integer)
data (Text)
columns on foo_relations:
def add_obj(session, obj):
Check if object primary key exists in db. If so,exit, else
add.
pid = obj.id
if session.query(obj.__class__).filter_by(id=pid).count():
print Patient object with id %s is already in db.%pid
exit
else:
On Dec 2, 2008, at 6:04 PM, Eric Ongerth wrote:
def add_obj(session, obj):
Check if object primary key exists in db. If so,exit, else
add.
pid = obj.id
if session.query(obj.__class__).filter_by(id=pid).count():
print Patient object with id %s is already in
On Dec 2, 2008, at 5:54 PM, Eric Ongerth wrote:
Now when I want to find out whether a Foo has a relation to another
Foo, I have to check whether there exists any row in foo_relations
that has the given Foo as either as this OR that. Also, what if I
need backrefs on the foo_relations
[This message has also been posted.]
Hi Eric,
Thanks very much for the improvement.
On Tue, 2 Dec 2008 15:04:34 -0800 (PST), Eric Ongerth
[EMAIL PROTECTED] wrote:
def add_obj(session, obj):
Check if object primary key exists in db. If so,exit, else
add.
pid = obj.id
[This message has also been posted.]
On Tue, 2 Dec 2008 18:25:19 -0500, Michael Bayer
[EMAIL PROTECTED] wrote:
On Dec 2, 2008, at 6:04 PM, Eric Ongerth wrote:
[snip]
Furthermore, if you really need to determine the object's class's
mapped table,
obj_table =