[英]How to debug cursor.execute (psycopg2) is NoneType
我尝试对我的postgres数据库运行SQL,
我通过的连接对象
import psycopg2
conn_string = "host='localhost' port='5432' dbname='postgres' user='postgres' password='mysecretpassword'"
conn = psycopg2.connect(conn_string)
似乎还可以
result = cursor.execute(
"""
select
*
from
planet_osm_point limit 10
""")
结果是Nonetype,所以一定有问题吗?
我做错了什么? 我该如何调试呢?
cursor.execute()
仅执行查询,不获取任何数据。 为了接收数据,您将需要调用cursor.fetchall()
或cursor.fetchone()
。
import psycopg2
conn_string = "host = 'localhost' port = '5432' dbname = 'postgres' user = 'postgres' password = 'mysecretpassword'"
conn = psycopg2.connect(conn_string)
cursor.execute(
"""
select
*
from
planet_osm_point limit 10
""")
result = cursor.fetchall()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.