I'm being forced to use python and pyodbc to do some basic database work and am encountering the following error which is confusing me:
pypyodbc.DatabaseError: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.')
The error is clear enough, but why it is expecting two parameters is perplexing me because here is the proceeding code which clearly only asks for a single parameter:
sqlCommand = "SELECT ProductID, Quantity FROM tblJobsProducts WHERE JobID = (?)"
jobProductData = executeGetSQLCMD(sqlCommand, [jobData[0][0]])
Where jobData[0][0]
is the JobID.
and executeGetSQLCMD
is:
def executeGetSQLCMD(sqlString, params=[]):
if len(params) <= 0:
crsr.execute(sqlString) # executes the SQL command
else:
crsr.execute(sqlString, params)
return crsr.fetchall()
The executeGetSQLCMD
appears to work just fine in all other cases.
Any idea what's wrong?