[sqlalchemy] Re: backref error when migrated to 0.4

2007-12-27 Thread Max Ischenko
Hello Bertrand, It works like a charm, thanks a lot. Max. On 12/27/07, Bertrand Croq [EMAIL PROTECTED] wrote: JobPosting's mapper tells RefdataLocation's mapper to add a property named 'vacancies', then you tell RefdataLocation's mapper to add a property named 'vacancies'. Replace these

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-27 Thread Rick Morrison
I think you're thinking of .load() .get() does not throw on not found. On 12/27/07, braydon fuller [EMAIL PROTECTED] wrote: you can also use 'try' to avoid error messages: def ensure_object(db, id): try: o = db.Query(ModelObject).get(id) except: o =

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-27 Thread Denis S. Otkidach
On Dec 26, 2007 10:38 PM, Michael Bayer [EMAIL PROTECTED] wrote: if you have an instance which you are unsure if it already exists, you can add it to a session using session.save_or_update(instance). The decision between INSERT and UPDATE is ultimately decided by the presence of an attribute

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-27 Thread Rick Morrison
...if you're just checking to see if something exists in the database, why not just try to .load() it, and then construct it afresh if you don't find it? This kind of operation is sometimes called an upsert ...some database engines support it, some don't. Most don't. But what all database engines

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-27 Thread braydon fuller
you can also use 'try' to avoid error messages: def ensure_object(db, id): try: o = db.Query(ModelObject).get(id) except: o = ModelObject(1, u'title') db.save(o) db.commit() return o -Braydon Rick Morrison wrote: ...if you're just checking to see

[sqlalchemy] filter_by() related table columns

2007-12-27 Thread [EMAIL PROTECTED]
I am attempting to upgrade from sqlalchemy 0.3.11 to current release 0.4.1 and i am getting the following error: /recs = session.query(PurchaseOrder).filter_by(description = 'Shipped').all() File C:\Python24\Lib\site-packages\sqlalchemy\orm\query.py, line 322, in filter_by clauses =