[sqlalchemy] Re: inferring object class/table directly

2008-12-03 Thread rdmurray
On Tue, 2 Dec 2008 at 23:21, Faheem Mitha wrote: Yes, I was looking for this, and printed out obj.__dict__ but didn't see it there. A dictionary of attributes is very useful in theory, but doesn't always seem to have all attributes. Is this documented anywhere? Try dir(obj). You'll see it

[sqlalchemy] Re: inferring object class/table directly

2008-12-03 Thread Faheem Mitha
On Wed, 3 Dec 2008 08:58:42 -0500 (EST), [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Tue, 2 Dec 2008 at 23:21, Faheem Mitha wrote: Yes, I was looking for this, and printed out obj.__dict__ but didn't see it there. A dictionary of attributes is very useful in theory, but doesn't always seem

[sqlalchemy] Re: inferring object class/table directly

2008-12-02 Thread Eric Ongerth
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:

[sqlalchemy] Re: inferring object class/table directly

2008-12-02 Thread Michael Bayer
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

[sqlalchemy] Re: inferring object class/table directly

2008-12-02 Thread Faheem Mitha
[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

[sqlalchemy] Re: inferring object class/table directly

2008-12-02 Thread Faheem Mitha
[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 =