Skip to content
Advertisement

scalars() leaving out column

I have the following code that should get the last known action of users and insert it’s timestamp in the user object:

JavaScript

This results in the following error:

JavaScript

Even though the column is being selected in the generated query:

JavaScript

Does anyone know why the user_id column is not showing up in the Event objects?

Update: It’s scalars() that is causing the issue. Without it this is the output of print(event):
(datetime.datetime(2016, 10, 7, 22, 0, 29), 1) After running scalars only the datetime is picked up
So scalars seems to completely disregard the last number which is the user_id. Why?

Advertisement

Answer

I was under the impression that scalars() was supposed to map the result to an object. Upon reading the docs more closely, it can only do this with one column. This (optional) parameter defaults to 0 (index of column) and hence only the datetime is picked up. I’m not using .scalars() anymore and instead have to do row[0], row[1]

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement