With pyodbc I can parametrize the query like this;
value = "testval"
query = \
"""
SELECT *
FROM TestTable
WHERE Column = ?;
"""
cursor.execute(query, value)
But the problem is that if the value is None, the query should look like this;
value = None
query = \
"""
SELECT *
FROM TestTable
WHERE Column IS NULL;
"""
cursor.execute(query)
So how should the query look like when the value can either be None or a string;
value = get_value() # can return a string or None
query = \
"""
SELECT *
FROM TestTable
WHERE Column ???????????
"""
cursor.execute(query, value)