Trying to do a shopping cart in telegram bot using psycopg2 and aiogram, but the data does not appear in the "korzina" column
code:
connection.cursor(f'INSERT INTO bot_users(korzina) VALUES({id_tovara}) FROM bot_user WHERE user_id= {us_id}')
connection.commit()
types of column’s:
user_id | bigint
korzina | text
I’m using postgresql.
Nothing happend with "korzina" column. All data write correct (name of column’s and table name)
2
Answers
You are calling
connection.cursor
with a very longname
parameter, which is most likely not what you had in mind.You probably want to create an unnamed cursor object, and then call its
execute
method:You may also want to look at the behaviour of connections and cursors when used as context managers.
The
INSERT INTO
command does not include theFROM
clause, you should instead modify your query to useUPDATE
, something like this;