Answer the question
In order to leave comments, you need to log in
Inserting data into Postgresql?
Hello. I'm learning python along with postgre and I want to execute the following query to the database
cursor.execute("INSERT INTO id_list(id) VALUES(?)", user_id)
I read somewhere that values(?) should be done to protect against sql injection , but when I execute
such a query in the postgre base, I get an error. What is the problem ??
When I do this, data is freely added to the table:
cursor.execute("INSERT INTO id_list(id) VALUES(372772)")
This numeric value is added.
Answer the question
In order to leave comments, you need to log in
cursor.execute("insert into id_list (id) values (%s)", (user_id, ))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question