Given the following sess query:
sess = DBSession()
reg = sess.query(Registration,Schedule).join(Schedule,Registration.classcode==Schedule.classcode).filter(Registration.registration_no==reg_id)
How the heck do I address the fields in the result 'reg'?
reg.timeofentry throws an error: TypeError: Can't convert 'int' object to str implicitly
I am rapidly learning to loath SQLAlchemy for all it's cryptic wrappers around perfectly simply SQL syntaxes.
oddly enough, the names within the named tuple row as returned from iterating the result reg in this case would be be Registration and Schedule:
for row in reg:
print row.Registration, row.Schedule
I'm not able to reproduce your specific error message "can't convert 'int' object to str implicitly". If I attempt to access a name on the KeyedTuple that doesn't exist, there's a clear message:
AttributeError: 'KeyedTuple' object has no attribute 'imfake'
The behavior of the return value of query should be less cryptic after reading the intro to Querying in the ORM tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With