【发布时间】:2025-12-01 07:35:01
【问题描述】:
我正在尝试遍历名为吞吐量的表中的所有行,但针对特定的 DeviceName(我已将其存储在 data['DeviceName'] 中。我尝试了以下方法,但它不起作用:
for row in cursor.execute("select * from Throughput where DeviceName=%s"), %(data['DeviceName']):
编辑:也试过这个,但它不起作用:
for row in cursor.execute("select * from Throughput where(DeviceName), values(?)", (data['DeviceName']) ):
EDIT2:我的最终工作代码的 sn-p:
query = "select * from Throughput where DeviceName = '%s'" % data['Device Name']
try:
for row in cursor.execute(query):
【问题讨论】:
-
“不起作用”怎么办?您收到什么错误或意外行为?
标签: python sql variables select pyodbc