On Thu, Apr 2, 2009, Jyotirmoy jmoy.mate...@gmail.com wrote:
On Apr 1, Yassen Damyanov yassen@gmail.com wrote:
You may prefer to use session.merge() leaving the SELECT and the
subsequent decision to INSERT or UPDATE to SQLAlchemy
On Thu, Apr 2, 2009, Yassen Damyanov yassen@gmail.com wrote:
Not sure if this is a good advice, but extending SessionExtension (in
orm/session.py)
SessionExtension is in orm/interfaces.py (my apologies).
Y.
--~--~-~--~~~---~--~~
You received this message
Jyotirmoy wrote:
I want to know what is the best way to write code using sqlalchemy
that given a value of the primary key inserts a record if no record
with that key exists or updates the value of the other columns if the
key already exists.
I wrote a naive version which get()s the value
You may prefer to use session.merge() leaving the SELECT and the
subsequent decision to INSERT or UPDATE to SQLAlchemy (see
http://www.sqlalchemy.org/docs/05/session.html?highlight=merge#merging)
The main section of your example should look like this then:
---snip---
id =
On Apr 1, 9:22 pm, Yassen Damyanov yassen@gmail.com wrote:
Jyotirmoy wrote:
I want to know what is the best way to write code using sqlalchemy
that given a value of the primary key inserts a record if no record
with that key exists or updates the value of the other columns if the
key