简体   繁体   中英

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!

如果[DB #]是数字,而[Case2]是文本,请尝试:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM