从psycopg2中的模式获取数据

2024-03-29 09:37:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在Python应用程序中连接Postgres数据库。 我使用psycopg2库。在

如果我像这样执行select语句:

cursor.execute("""select schema_name from information_schema.schemata;""")
rows = cursor.fetchall()
print(rows)

我得到:

^{pr2}$

但如果我执行语句

cursor.execute("""select * from DB_FZ.d_results;""")
rows = cursor.fetchall()
print(rows)

我搞错了

psycopg2.ProgrammingError: schema "db_fz" does not exist
LINE 1: select * from DB_FZ.d_results;

怎么了?在


Tags: from应用程序executedbschemapostgres语句select