facing Too few parameters. Expected 1. (-3010) (SQLExecDirectW)')" error in python program

一个人想着一个人 提交于 2019-12-13 06:47:52

问题


using python "pyodbc" module for extarcting data from excel sheet. When I use numeric instead of win_b64, This program works, for string i.e. win_b64 It is showing below error. I want to retrive data like in below condition "where platform = win_b64 and context_id = 806"

import pyodbc
exFile = r'C:\Python34\abc.xls'conn1 = pyodbc.connect('DRIVER={MicrosoftExcel Driver (*.xls)};DBQ='+exFile,autocommit=True)

curs1 = conn1.cursor()
excel = curs1.execute('select [problem_name] from [Sheet1$] where platform_name = win_b64 ;').fetchall()
p = (excel)
for x in p:
    print(x[0])

Error:

pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Excel Driver] Too few parameters. Expected 1. (-3010) (SQLExecDirectW)')


回答1:


Solution:

excel = curs1.execute('''select [problem_name] from [Sheet1$] where platform_name = 'win_b64' ;''').fetchall() 

-> query syntax should be start in triple quot...and end too.



来源:https://stackoverflow.com/questions/34082907/facing-too-few-parameters-expected-1-3010-sqlexecdirectw-error-in-pyth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!