angel285
angel285

Reputation: 265

sqlite3.OperationalError: near "=": syntax error

I have a SQLite Database with some data. Now I want to update this data with Python.

This is the Python code I use:

print("Place your tag to activate it...")
forename = input("Forename: ")
surename = input("Surename: ")
permission= input("Permission: ")
_id = Rfid.readRfid()
cursor.execute("UPDATE rfidTage SET (forename = ?, surename = ?, permission = ? WHERE id = ?)", (str(forename), str(surename), str(permission), long(_id)))

The method Rfid.readRfid() just reads the Rfid tag and returns the id as long.

I tried to run the code and got the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "DatabaseWriter.py", line 27, in updateTag
    cursor.execute('''UPDATE rfidTage SET (forename = ?, surename = ?, permission = ? WHERE id = ?)''', (str(forename), str(surename), str(permission), long(_id)))
sqlite3.OperationalError: near "=": syntax error

I would appreciate any help.

Upvotes: 0

Views: 1334

Answers (1)

aveuiller
aveuiller

Reputation: 1551

You should not use the parentheses after your SET operator. You can have more details on the following resources:

Your query should be UPDATE rfidTage SET forename = ?, surename = ?, permission = ? WHERE id = ?.

Upvotes: 2

Related Questions