-2

I am trying to input the score to a quiz into a database in which the user already has an account.

I am getting an error saying - "sqlite3.OperationalError: near "WHERE": syntax error"

conn.execute("INSERT INTO PlH WHERE username == (?) VALUES (?)",(username,score))
conn.commit()

The column names in the sql database are named 'PlH' and 'username' and the variables are 'score' and 'username' respectively

2
  • To change a value of an already created row, use UPDATE PlH SET score = ? WHERE username = ?. Don't use ==, use = in SQL. See SQLite Update. Commented Sep 4, 2021 at 16:40
  • To change an existing row use update. Commented Sep 4, 2021 at 16:40

1 Answer 1

0

If I understood your question properly, you want to refresh the record in the table not to insert a new one. For this purpose you need to use UPDATE statement instead. WHERE clause of the script will be used to identify the required row (sometimes used for the list of rows updated simultaneously). SET clause wil specify the list of fields and new values to be assigned. Read SQLite documentation for the syntaxis.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.