Using sqlalchemy with automap from a .SQL file, and up until now, everything has been great. Yesterday, I added a boolean column to a table in the .SQL file, but when attempting to access the new field, I get:
object has no attribute
This is when attempting to access the column in the query result.
If I set a breakpoint() and run dir() on the generated model, I can see the name in the list, but I get the error when running the code.
I prepped an anonymous code example, and it made things even more awkward. This works:
Anonymized code examples:
val = db.session.query(BaseModels.classes.TableName).first()
check_column = val.broken_new_column
But this does not:
vals = db.session.query(BaseModels.classes.TableName).filters(BaseModels.classes.TableName.test_col == 5).all()
check_column = vals[0].broken_new_column
I am a little stumped. Looking into it further, I see other columns I haven’t used before are behaving similarly.