no results to fetch, but the SELECT count(id) should always return result
geotransformer opened this issue · comments
Vincent commented
This is a bug tracker
If you have a question, such has "how do you do X with Python/PostgreSQL/psycopg2" please write to the mailing list or open a question instead.
Please complete the following information:
- OS: Ubuntu
- Psycopg version: 2.9.6
- Python version: 3.8
- PostgreSQL version: 13.5
- pip version pip3
Describe the bug
Please let us know:
1: what you did
2: what you expected to happen
3: what happened instead
If possible, provide a script reproducing the issue.
def enforce_max_alert_count(self, new_alerts_count=0):
try:
self.check_and_connect()
self.db_cursor.execute("SELECT count(id) from history_v02")
row = self.db_cursor.fetchone()
in enforce_max_alert_count\n row = self.db_cursor.fetchone()\npsycopg2.ProgrammingError: no results to fet
ch\n"
Daniele Varrazzo commented
You are doing something wrong in your code.
In [22]: import psycopg2
In [23]: conn = psycopg2.connect("")
In [24]: cur = conn.cursor()
In [25]: cur.execute("create table empty (id serial primary key)")
In [26]: cur.execute("select count(id) from empty")
In [27]: cur.fetchone()
Out[27]: (0,)