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 [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to