我想遍歷表中的所有行命名吞吐量,但對於特定的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