I’m failing to read the data from a result into the correct type, for example:
result = engine.execute("SELECT id FROM table WHERE SetId = 5).fetchall()
Column id is of type Long in the MySQL DB
print result
[(1L,), (2L,), (3L,), (4L,), (5L,), (6L,)]
for row in result:
print row
(1L,) etc..
print type(row)
<class 'sqlalchemy.engine.base.RowProxy'>
What is the best way reading those values as the correct type Long? I really don’t get how to correctly read out the values from the RowProxy class in general
SQLAlchemy
RowProxyinstances are not strings, but objects with a string representation when printed.They act like lists and mappings; if all you need are the long values, just loop over the row:
or address each column in the row by it’s index:
Your query asks for the column
id, so that is now a key on the row: