1
我想從Track Table更新TrackId的UnitPrice。 UnitPrice和TrackId通過用戶輸入給出參數。我目前正在接受對參數的數目錯誤:多佔位符SQLite蟒蛇不工作
Traceback (most recent call last):
File "HW4.py", line 48, in <module>
conn.execute("UPDATE Track set UnitPrice = ? WHERE TrackId = ?", (n_price,t_id))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
這裏是我的代碼:
track_id = raw_input('Enter Track ID\n')
t_id = (track_id,)
cur = conn.execute("SELECT T.UnitPrice FROM Track T WHERE T.TrackId = ?", t_id)
for row in cur:
print "Unit Price: ", row[0]
new_price = raw_input('Enter New Price\n')
n_price = (new_price,)
conn.execute("UPDATE Track set UnitPrice = ? WHERE TrackId = ?", n_price, t_id)
conn.commit
print "Total number of rows updated: ", conn.total_changes
cur = conn.execute("SELECT T.UnitPrice FROM Track T WHERE T.TrackId = ?", t_id)
for row in cur:
print "Unice Price: ", row[0]
我猜這是我如何把n_price和T_ID到語法錯誤?佔位符。
您追蹤消息不匹配您的發佈代碼。 –