首页 > 解决方案 > Heroku Postgres:psycopg2.ProgrammingError:没有要获取的结果

问题描述

我正在从我的树莓派连接到托管在 heroku 上的 postgres,但是每当我尝试使用它运行查询时,psycopg2我只得到错误。我已经用谷歌搜索了一堆错误,但没有一个是真正相关的。任何帮助将不胜感激。(出于明显的原因,我编辑了连接信息)

我的代码:

import psycopg2

connection = psycopg2.connect("""dbname={REDACTED}
 host={REDACTED}
 port={REDACTED}
 user={REDACTED}
 password={REDACTED}
 sslmode=require
""")
cursor = connection.cursor()

data = cursor.fetchone()
print("Connection Established With: ", data)

connection.commit()
connection.close()

错误: psycopg2.ProgrammingError: no results to fetch

标签: databasepostgresqlherokupsycopg2heroku-postgres

解决方案


推荐阅读