Here are the SQL code as string in python:
sql_code="""
SELECT VAR
VAR2
FROM TABLE
WHERE VAR in ('A','B')
"""
And I would like to create a variable for the list of selection in the WHERE clause, this is what we can do:
sql_code_arg1="""
SELECT VAR
VAR2
FROM TABLE
WHERE VAR in {}
"""
Then
lst=["A","B"]
print(sql_code_arg1.format(tuple(lst)))
Now, I would like to parameter the entire condition in WHERE clause:
sql_code_arg2="""
SELECT VAR
VAR2
FROM TABLE
WHERE {}
"""
I tried someting like this:
print(sql_code_arg2.format("VAR in "+tuple(list)))
But it doesn't work.