Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.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从Postgresql中基于模式的表中选择数据_Python_Python 3.x_Postgresql_Python 2.7_Psycopg2 - Fatal编程技术网

Python 使用psycopg2从Postgresql中基于模式的表中选择数据

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

我是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.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")