V
V
violpeople2021-08-01 18:42:05
Python
violpeople, 2021-08-01 18:42:05

How to add data to DB with certain conditions?

I am using Aiogram. I need to enter data into the database by username.
I thought to do it via INSERT:

cur.execute('''INSERT INTO users(user_item, user_price) VAlUES (?, ?) WHERE user_name = value''',(user,))

But it throws an error:
sqlite3.OperationalError: near "WHERE": syntax error

I surfed further on the Internet, but saw that the "where" operator is used only with select, update and delete.
So the question is - how to add data in my case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
UberPool, 2021-08-02
@UberPool

View SQL Documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question