Psycopg2.ProgrammingError: syntax error at or near "ON"

This one drove me crazy. I looked online. My database is Postgres 9.5.4. I am using python 3 and psycopg2 2.7.1

I am getting the following error

psycopg2.ProgrammingError: syntax error at or near "ON"
LINE 2:                       ON CONFLICT do nothing

      

And my code:

    try:
        c = db.cursor()
        c.execute("""INSERT INTO my_table (id, name, tstmp)
                  VALUES (%s,%s,%s)
                  ON CONFLICT do nothing""",
                  (id, name, tstmp))
    finally:
        c.close()

      

Is ON

psycopg2 not supported or am I doing something wrong?

+3


source to share





All Articles