'SQLAlchemy table, one column is being created but the other isn't?
I'm at a loss about why I get the message Could not locate column in row for column 'HasFS'. If I remove HasFS = 'Y' and HasFS: { row.HasFS } then a bunch of client IDs are returned as expected with no error. What is different between the two? ClientId is being added from the results of another query, whereas I'm just putting a custom string into HasFS, but I can't imagine that is the problem.
with R201_Session.begin() as session:
has_fs = table('has_fs', column('ClientId'), column('HasFS'), column('Start'))
has_fs_query = ...
for row in has_fs_query:
has_fs.insert().values(ClientId = row.ClientId, HasFS = 'Y')
print(f'ClientID: { row.ClientId }, HasFS: { row.HasFS }')
Edit: The error log points to the print() line so evidently it's not a problem one line above that where it's inserting values into said column??
Edit2: I can confirm the columns exist using the output of the following code:
from sqlalchemy.inspection import inspect
print([column.name for column in inspect(has_fs).c])
Edit3: Okay so that for loop is for a different table that doesn't have HasFS, not the has_fs table. The has_fs_query is misleading. Trying to sort out the proper way to do this then I'll post an answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
