Are prepared statements written differently in psycopg3 than psycopg2?
I am upgrading from psycopg2 to 3 and in psycopg2 this works but doesnt work for psycopg3
Also the variables name
and age
will be populated with data
sql
is a variable which is connected to the Database we use. So my problem is within the query itself and not the python syntax
def test(name, age=None, alive=False):
sql.execute("""prepare test as UPDATE table AS x
SET var = $1
FROM table1 as y
WHERE y.name = x.name and y.age = $2""")
sql.execute("""execute test (%s, %s)""", (name, age))
This throws an error saying could not determine the datatype of parameter $1
. Looking at the docs and github of psycopg, theres no info regarding this matter.