well if youre updating with an expression like that, i think youre on
the right track:
connection = session.connection()
connection.execute(Orders.update(Orders.c.priority>5, values=
{Orders.c.priority:Orders.c.priority+1}))
theres some test cases that test using expressions in the SET clause
in test/sql/select.py, around line 615. the "+" operator is
overloaded in a Column object to produce a SQL expression.
On Aug 9, 2006, at 7:17 PM, Brad Clements wrote:
> I need to do an update like this:
>
> connection.execute('update orders set priority = priority - 1 where
> priority
>> = :priority', priority=order.priority)
>
> I am using explicit sessions, so trying
>
> connection = session.connection()
>
> But, I was looking at
>
> http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_update
>
> And trying to figure out how to do something like:
>
> Orders.update(
> Orders.c.priority >= priority,
> values={Orders.c.priority:Orders.c.priority+1}
> )
>
> First, I don't expect that update to work because adding 1 to a
> column doesn't
> make sense, and second I couldn't see how Orders gets its engine
> context.
>
> Then I see other examples like
>
> connection.execute(Orders.update(), {values})
>
> and I'm perplexed at what Orders.update() is returning..
>
>
>
> --
> Brad Clements, [EMAIL PROTECTED] (315)268-1000
> http://www.murkworks.com
> AOL-IM or SKYPE: BKClements
>
>
>
> ----------------------------------------------------------------------
> ---
> Using Tomcat but need to do more? Need to support web services,
> security?
> Get stuff done quickly with pre-integrated technology to make your
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users