A
A
Artur2020-06-29 20:04:08
Python
Artur, 2020-06-29 20:04:08

How to change value in SQLite?

nickname = input('Введите ник: ')
user_login = int(1) #1 для примера

sql.execute(f'UPDATE users SET nick = {nickname} WHERE login = "{user_login}"')
db.commit()


Error occurs:
sqlite3.OperationalError: no such column: cucumber

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2020-06-29
@rackev

Single quotes must be used. And here nick = {nickname}, and here login = "{user_login}"
But better, as said above:

sql.execute(f'UPDATE users SET nick = ? WHERE login = ?', (nickname, user_login))

S
Sergey Gornostaev, 2020-06-29
@sergey-gornostaev

5c36ceb55373a271424607.png
Using string interpolation to generate sql query is a very bad idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question