How about some sort of literal: "table1.col1 * 5" (without the quotes)
as the value of a bindparam?  So to the bindparam it would look like a
constant, but when it got to the server, it would be interpreted as an
expression?  I would be loosing the automatic table/column name
insertion that SA provides.



On May 20, 8:01 am, Conor <conor.edward.da...@gmail.com> wrote:
> On 05/20/2010 09:56 AM, Bryan wrote:I know this has got to be simple. I am 
> updating "table1" in MySQL. u = table1.update() 
> u.values(col1=bindparam('_col1'), col2=bindparam('_col2') ... updateVals = [ 
> {'_col1': 5, '_col2': table1.col1 * 5} ] engine.execute(u, updateVals) I was 
> expecting table1.col1 * 5 to show up as: `table1`.`col2` = `table1`.`col1` * 
> 5 But it shows up as: '`table1`.`col1` * %s' in the query log. Note the 
> quotes around the actual result, and the missing 5 value. The 5 is never 
> being placed into the string being sent to the server.
>
> You are not allowed to use expressions as bind params, only constants. Bind 
> params are not allowed to change the "structure" of the SQL statement, 
> because part of the reason for bind params in the first place is the server 
> only has to parse/plan the SQL statement once, regardless of how many items 
> you put in updateVals.
>
> -Conor
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to