kevinvi8
kevinvi8

Reputation: 321

pyodbc Syntax Issue 'Too few parameters. Expected 2'

I have looked at several different similar examples here on Overflow and haven't had any luck finding a solution to my issue. The offending line appears to be the following:

cmd = "'''UPDATE [Python_Test] SET [DB #] = ['123456798'] WHERE Case2 = 
            ['ZZZ00000']'''"

I run this using the following command (which 100% works when I do INSERT pyodbc commands):

crsr.execute(eval(cmd))

As the title implies, I keep getting the following error message: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. (-3010) (SQLExecDirectW)')

I've seen several times that special characters can cause issues, but I believe I have taken necessary precautions against that type of issue, but maybe someone can see something that I have totally missed.

If anyone needs any follow-up info please feel free to let me know!

Upvotes: 0

Views: 324

Answers (1)

Gustav
Gustav

Reputation: 55831

If [DB #] is numeric and [Case2] is text, try with:

cmd = "UPDATE [Python_Test] SET [DB #] = 123456798 WHERE [Case2] = 'ZZZ00000'"

Upvotes: 1

Related Questions