Python 使用psycopg2从Postgresql中基于模式的表中选择数据
我是Python新手,希望使用Python psycopg2 API从postgreSQL数据库中选择一些数据 我选择的表位于模式dl(dl.products)中,因此当我编写代码时Python 使用psycopg2从Postgresql中基于模式的表中选择数据,python,python-3.x,postgresql,python-2.7,psycopg2,Python,Python 3.x,Postgresql,Python 2.7,Psycopg2,我是Python新手,希望使用Python psycopg2 API从postgreSQL数据库中选择一些数据 我选择的表位于模式dl(dl.products)中,因此当我编写代码时 Conn= psycopg2.connect(host="localhost",database="postgres",user="postgres", password="postgres") Cur=conn.cursor() Cur.execute("select * from dl.produc
Conn= psycopg2.connect(host="localhost",database="postgres",user="postgres", password="postgres")
Cur=conn.cursor()
Cur.execute("select * from dl.products")
它显示了错误关系dl。产品不存在
有人能给我举个例子吗?请尝试下面的代码
Query = """select * from dl."products";"""
cursor.execute(Query)
print("Selecting rows from test table using cursor.fetchall")
row = cursor.fetchone()
while row is not None:
print(row)
row = cursor.fetchone()
print("Print each row and it's columns values")