psycopg2.ProgrammingError:关系不存在

时间:2019-03-17 18:18:19

标签: python psycopg2

我正在ubuntu VM(192.168.178.200)上运行PostgreSQL,并尝试使用psycopg2从其他设备连接到它。

代码:

import csv
import psycopg2

conn = psycopg2.connect(
    host="192.168.178.210",
    database="pwned",
    user="postgres",
    password="postgres",
    port="5432"
)

cur = conn.cursor()

print(conn.get_dsn_parameters())
cur.execute("SELECT version();")
record = cur.fetchone()
print("You are connected to - ", record)

fileList = ["part1.txt", "part2.txt", "part3.txt"]

output = cur.execute(""" SELECT * from pwned """)

这是我得到的输出:

{'tty': '', 'sslcompression': '1', 'dbname': 'pwned', 'options': '', 'host': '192.168.178.210', 'target_session_attrs': 'any', 'user': 'postgres', 'sslmode': 'prefer', 'port': '5432', 'krbsrvname': 'postgres'}
('You are connected to - ', ('PostgreSQL 10.6 (Ubuntu 10.6-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0, 64-bit',))
Traceback (most recent call last):
  File "/Users/in0cent/Documents/Dev/Personal/MassImportPwned/Import.py", line 21, in <module>
    output = cur.execute(""" SELECT * from pwned """)
psycopg2.ProgrammingError: relation "pwned" does not exist
LINE 1:  SELECT * from pwned 

我在做什么错?还是psycopg2是使用python连接到postgresql的错误库?

谢谢

0 个答案:

没有答案