我正在尝试在 Python 脚本中执行 SQL 存储过程,但遇到语法问题。我尝试了我找到的各种示例的组合,但似乎没有一个起作用。这是我尝试过的:
county = 100200
confirmed = 123456
death = 12
labTestCount = 0
#Example1
conn.execute('{CALL [spInsertCOVIDData](@County,@Confirmed,@Death,@LabTestCount)}', ('county', 'confirmed', 'death', 'labTestCount'))
#Example2
query = "EXEC [spInsertCOVIDData] (@County,@Confirmed,@Death,@LabTestCount)", (county, confirmed, death, labTestCount)
conn.execute(query)
#Example3
query = "EXEC [spInsertCOVIDData] @County=?, @Confirmed=?, @Death=?, @LabTestCount=?",(county, confirmed, death, labTestCount)
conn.execute(query)
#Example4
query = "EXEC [spInsertCOVIDData] @County='county', @Confirmed='confirmed', @Death='death', @LabTestCount='labTestCount'"
conn.execute(query)
我从以下位置得到了各种错误的混合:
('The SQL contains 0 parameter markers, but 4 parameters were supplied', 'HY000')
或者
The first argument to execute must be a string or unicode query.
慕哥6287543
相关分类