'pd.read_sql_query: 'params' arg (<class 'list'>) can be only a tuple or a dictionary

I am receiving the error:

'params' arg (<class 'list'>) can be only a tuple or a dictionary.

My code is follows:

conn = pymssql.connect(server='server', user='user', password='pwd', database='db')

cursor = conn.cursor()

year = date.year

month = date.month

day = date.day

params = (year, month, day)

sql = open(f'{sql_path}/sqlfile.sql', 'r')

sql_cmd = sql.read()

client_trades = pd.read_sql_query(sql_cmd, conn, params = params)

However print(type(params)) returns <class 'tuple'> so I am unsure as to where the error comes from

Furthermore this same code was working fine yesterday and I have not made any changes since, I have tried params = tuple((year, month, day)) and params = (str(year), str(month), str(day)) but to no avail as I receive the same error



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source