尝试通过Psycopg2向PostgreSQL DB表添加值时出现编程错误消息

时间:2019-05-24 20:54:26

标签: python-3.x postgresql psycopg2

当我将SQL查询插入到PostgreSQL中时,我收到了来自psycopg2的以下错误,但我不确定我要去哪里哪里

错误消息:

testing-01% sudo python3 ./tables.py
Traceback (most recent call last):
  File "./tables.py", line 18, in add_cols
    cursor.execute("INSERT INTO "+table_name+" (Fieldtest1, Fieldtest2, Fieldtest3, Fieldtest4, Fieldtest5, Fieldtest6) VALUES ('Row6', 'Row6', 'Row6', 'Row6', 'Row6', 'Row6');")
psycopg2.ProgrammingError: column "fieldtest1" of relation "test" does not exist
LINE 1: INSERT INTO test (Fieldtest1, Fieldtest2, Fieldtest3, Fieldt...

正在执行的table.py中的查询语句:

cursor.execute("INSERT INTO testname (Fieldtest1, Fieldtest2, Fieldtest3, Fieldtest4, Fieldtest5, Fieldtest6) VALUES ('Row6', 'Row6', 'Row6', 'Row6', 'Row6', 'Row6'));

我正在使用的数据库中已经设置了列名。想法?

0 个答案:

没有答案