Skip to content
Advertisement

Iterating over 2 lists in SQL execution using SQL Alchemy

I currently have this query:

JavaScript

That I changed to use bindparams:

JavaScript

So before, I was able to make the query per table in the bmds_stage_table list and change_set_ids was just 1 int

But now change_set_ids is a list of ints.

So now, for each change_set_id I want to iterate through all the tables in the bmds_stage_table list

With the change I had to adjust how I execute the query:

JavaScript

But I get this error:

JavaScript

I would greatly appreciate any help!

Advertisement

Answer

Consider formatting the table name to raw SQL since identifiers cannot be parameterized and bind_params for literal values:

JavaScript

Possibly, too, consider the functional form of sqlalchemy:

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