我想遍历表中的所有行命名吞吐量,但对于特定的DeviceName(我已经存储在数据['DeviceName']]我已经试过以下,但它不工作:pyodbc - 如何使用参数执行一个选择语句使用变量
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:我的最终工作代码片段:
query = "select * from Throughput where DeviceName = '%s'" % data['Device Name']
try:
for row in cursor.execute(query):
“不工作”怎么样?你收到什么错误或意外的行为? – Andy 2012-03-01 15:17:49