I have the following function which executes a query on a PostgreSQL db:
def execute_query(query):
con, cur = connect_to_db()
cur.execute(query)
con.commit()
con.close()
When I try to submit a query which includes %s, the %s is considered as an additional argument, which produces the following error:
TypeError: execute_query() takes 1 positional argument but 2 were given
How can I include %s without producing this error? Sample:
execute_query( """ DELETE FROM table WHERE column = %s """, [x[0]])