问题
I'm checking whether a given transactionid exists in my sqlite database with this code.
print((transaction.transactionid,))
print(type(transaction.transactionid))
c.execute("SELECT EXISTS(SELECT transactionid FROM Transactions WHERE transactionid=?);",
(transaction.transactionid,))
self.dbconn.commit()
transaction_exists, = c.fetchone()
print(transaction_exists)
It always fails with this error on the second iteration:
File "RtMetaMaster.py", line 182, in sync_ticket_to_db (transaction.transactionid,)) sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
Output of the print statements:
('626007',)
<class 'str'>
0
('625952',)
<class 'str'>
Traceback (most recent call last):
[..]
File "RtMetaMaster.py", line 182, in sync_ticket_to_db
(transaction.transactionid,))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
Both times the transactionid is of type class 'str' but it somehow fails the second time. What other mistakes could lead to "Error binding parameter"?
回答1:
I solved it by adding a self.dbconn.commit() after every c.execute call. There's probably a better solution for this.
来源:https://stackoverflow.com/questions/44498628/other-reasons-for-sqlite3-interfaceerror-error-binding-parameter-0-probably-u