If I execute an sql command (its MS SQL Server 2016 as specified above) using pyodbc and pass 'None' as the parameters, I'm expecting it to run a command that takes no parameters, like "waitfor delay '00:00:10'" without error, but actually it gives:
pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000').
sql = "waitfor delay '00:00:10'"
sql_params = None
with pyodbc.connect(settings.Application_Conn, autocommit=True) as conn:
crsr = conn.cursor()
crsr.execute(sql, sql_params)
Is there a way using pyodbc to include the sql_params parameter in the crsr.execute but allow it to be 'empty' somehow and not fail when called against a command which takes no parameters, or maybe this is already possible ?
Environment
Issue
If I execute an sql command (its MS SQL Server 2016 as specified above) using pyodbc and pass 'None' as the parameters, I'm expecting it to run a command that takes no parameters, like "waitfor delay '00:00:10'" without error, but actually it gives:
pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000').
Is there a way using pyodbc to include the sql_params parameter in the crsr.execute but allow it to be 'empty' somehow and not fail when called against a command which takes no parameters, or maybe this is already possible ?