On Jan 30, 2011, at 8:55 PM, ObjectEvolution wrote:
> Hi,
>
> I'm reflecting some tables out of MySQL for a User object and when I
> call:
>
> user.ID
>
> I get a value like this:
>
> 10L
>
> instead of:
>
> 10
>
> If I wrap it up like this:
>
> int(user.ID)
>
> I get:
>
> 10
>
> It seems that the reflection thinks my int column is a long. Why is
> that happening and how can I fix it? Abandon reflection?
MySQL-python returns ints as Python longs. They are cross compatible.
SQLA's reflection is not involved.
from sqlalchemy import *
e = create_engine('mysql://scott:tiger@localhost/test')
print repr(e.scalar(select([1])))
print repr(e.scalar(select([cast(1, Integer)])))
raw_mysqldb_connection = e.connect().connection
cursor = raw_mysqldb_connection.cursor()
cursor.execute("select 1")
print cursor.fetchall()
output:
1L
1L
((1L,),)
--
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.