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