Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python psycopg2.ProgrammingError:语法错误位于或接近;关于;_Python_Postgresql_Psycopg2 - Fatal编程技术网

Python psycopg2.ProgrammingError:语法错误位于或接近;关于;

Python psycopg2.ProgrammingError:语法错误位于或接近;关于;,python,postgresql,psycopg2,Python,Postgresql,Psycopg2,这件事让我抓狂。我在网上看了看。 我的数据库是Postgres 9.5.4。 我正在使用python 3和psycopg2 2.7.1 我得到以下错误 psycopg2.ProgrammingError: syntax error at or near "ON" LINE 2: ON CONFLICT do nothing 我的代码是: try: c = db.cursor() c.execute("""INS

这件事让我抓狂。我在网上看了看。 我的数据库是Postgres 9.5.4。 我正在使用python 3和psycopg2 2.7.1

我得到以下错误

psycopg2.ProgrammingError: syntax error at or near "ON"
LINE 2:                       ON CONFLICT do nothing
我的代码是:

    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()

psycopg2是否不支持
ON
,或者我做错了什么?

您对使用9.5有多大把握<代码>从光标中选择版本()。