How do you insert values into a dynamic column name in SQLAlchemy? I am trying to insert values into a table using dynamic column names that are passed into the function.
I have tried:
field_id = "column_name"
query = (
insert(
TableName
)
.values(
getattr(TableName.c, field_id)=value
)
)
But that tells me I can't assign a value to an expression
SyntaxError: expression cannot contain assignment, perhaps you meant \"==\"?"