N
N
new_year20212020-12-28 01:35:18
Python
new_year2021, 2020-12-28 01:35:18

I want to add a value to the database but it gives an error why?

Here is the code where I want to add the user_id_v variable to the user_id table,
but it writes there is no column, but of course it will not exist if I want to add it :(

con = psycopg2.connect(
                host='localhost',
                database='Drive_in',
                user='postgres',
                password='42661902',
                port=5432
            )
            curr = con.cursor()

            curr.execute(f"""INSERT INTO users_id (user_id) VALUES ({user_id_v})""")
            con.commit()
            con.close()

psycopg2.errors.UndefinedColumn: ERROR: column "a535821263" does not exist
LINE 1: INSERT INTO users_id (user_id) VALUES (a535821263);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@malving, 2020-12-28
_

You need to send a tuple i.e.

INSERT INTO users_id (user_id) VALUES (?), (user_id,)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question