Does this work instead:
table.update().values(empno = cast(table.c.empno,Integer)).execute()
ie. a bare 'empno' inside your cast expression is just referring to a python
variable 'empno', which you've probably set to the value 'testing' at some
other point in your code. You need the column object table.c.empno instead
Hope that helps,
Simon
pravin battula wrote
Mike,
when i execute the below sql statement directly in the database using
sqlyog,it works fine but when tried with sqlalchemy it didn't.
update mytable set EmpMaster = cast(empno as UNSIGNED INTEGER)
On Sep 14, 8:23 pm, pravin battula pravin.batt...@gmail.com wrote:
Hi Mike,
I'm using Mysql 5.0 backend
On Sep 14, 8:20 pm, Mike Conley mconl...@gmail.com wrote:
Don't know what database you are using, but this looks like you
are trying
to cast the string 'testing' to an integer and the database
engine says you
can't do that.
--
Mike Conley
On Wed, Sep 14, 2011 at 9:51 AM, pravin battula
pravin.batt...@gmail.comwrote:
Sorry for the spelling mistake.It shows an error as below.
OperationalError: (OperationalError) (1292, Truncated
incorrect
INTEGER value: 'testing') 'UPDATE test.mytable SET
`newColumn`=CAST(test.mytable.`empno` AS SIGNED INTEGER)' ()
On Sep 14, 6:48 pm, pravin battula pravin.batt...@gmail.com
wrote:
Hi,
I'm using cast to update values in a table by issuing
following
command.
table.update().values(empno = cast(empno,Integer)).execute().
Where as empno is an string field,i'm trying to convert the
data from
empno column from string to integer and then issuing the
below command
to alter the data type of the column by issuing following
command.
alter_column(table.c.empno,type=Integer).
It shows an error as
OperationalError: (OperationalError) (1292, Truncated
incorrect
INTEGER value: '1d') 'UPDATE test.mytable SET
`newColumn`=CAST(CAST(%s AS CHAR) AS SIGNED INTEGER)' ('1d',)
Please do the needful
--
You received this message because you are subscribed to the
Google Groups
sqlalchemy group.
To post to this group, send email to
sqlalchemy@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 sqlalchemy@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 sqlalchemy@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.