l******9 发帖数: 579 | 1 【 以下文字转载自 Quant 讨论区 】
发信人: light009 (light009), 信区: Quant
标 题: error run SQL query from pyodbc python 3.2.5
发信站: BBS 未名空间站 (Thu Jun 19 12:04:26 2014, 美东)
I am working on pyodbc in Eclipse (4.3.2v20140221-1852) with PyDev on Win 7.
My python is 3.2.5.
At my code:
cursor.execute("select top " + str(1) + " a.my_id, a.mycode" +
"from my_table as a where a.mycode = ?", aGivenCode)
I got an error :
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server
Driver]
[SQL Server]Incorrect syntax near the keyword 'as'. (156) (SQLExecDirectW)")
Why I got error at " as a " ?
thanks ! | g*******7 发帖数: 269 | 2 不一定就错在As,我猜是你的那几个代入的变量有问题,你最好看看真正执行的SQL就什
么样子,或者贴出来。
7.
【在 l******9 的大作中提到】 : 【 以下文字转载自 Quant 讨论区 】 : 发信人: light009 (light009), 信区: Quant : 标 题: error run SQL query from pyodbc python 3.2.5 : 发信站: BBS 未名空间站 (Thu Jun 19 12:04:26 2014, 美东) : I am working on pyodbc in Eclipse (4.3.2v20140221-1852) with PyDev on Win 7. : My python is 3.2.5. : At my code: : cursor.execute("select top " + str(1) + " a.my_id, a.mycode" + : "from my_table as a where a.mycode = ?", aGivenCode) : I got an error :
|
|