How to use UPDATE?
Opened this issue · 0 comments
hevnsnt commented
I am trying to update an existing record, and it seems like the changes are not committed. What am I doing wrong here?
>>> from sqlite3worker import Sqlite3Worker
>>>
>>> sql_worker = Sqlite3Worker("/tmp/test.sqlite")
>>> sql_worker.execute("CREATE TABLE tester (fName TEXT, uuid TEXT)")
>>> sql_worker.execute("INSERT into tester values (?, ?)", ("Taka", "bow"))
>>> sql_worker.execute("INSERT into tester values (?, ?)", ("Barking", "dog"))
>>> results = sql_worker.execute("SELECT * from tester")
>>> for fName, uuid in results:
... print(fName, uuid)
...
(u'Taka', u'bow')
(u'Barking', u'dog')
>>> sql_worker.execute("UPDATE tester SET fName = ? WHERE uuid = ?", ("chicka", "bow"))
>>> for fName, uuid in results:
... print(fName, uuid)
...
(u'Taka', u'bow')
(u'Barking', u'dog')
>>>