following the documentation for SQL String composition , I want to execute a DELETE statement in my postgresql database:
db_cursor.execute(sql.SQL("DELETE FROM {}".format(sql.Identifier(table_name))))
This results in the error:
File "try_pandas.py", line 189, in _store_in_table
db_cursor.execute(sql.SQL("DELETE FROM {}".format(sql.Identifier(table_name))))
psycopg2.ProgrammingError: syntax error at or near "("
LINE 1: DELETE FROM Identifier('fixture_identification')
Another, similar execute is working fine:
db_cursor.copy_expert(sql.SQL("COPY {} FROM STDIN WITH CSV HEADER").format(sql.Identifier(table_name)), table_file)
I really don't see the difference...
The difference is here:
sql.SQL("DELETE FROM {}".format())
It should be
sql.SQL("DELETE FROM {}").format() # Notice the brackets.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.