psycopg2 - Using SQL object with execute_values
The parameter sql
in execute_values(cur, sql, argslist, template=None, page_size=100)
is supposed to be a string:
sql – the query to execute. It must contain a single %s placeholder, which will be replaced by a VALUES list. Example: "INSERT INTO mytable (id, f1, f2) VALUES %s".
Use the as_string(context)
method:
extras.execute_values(cursor, query.as_string(cursor), dataset)
connection.commit()