Python Psycopg2 Cursor.fetchall() Returns Empty List But Cursor.rowcount Is > 1
Solution 1:
I also faced the same issue. I figured out that, Might be while debugging, we are allowing some fraction of time after connection has been made #conn = psycopg2.connect(conn_string) #cursor = conn.cursor()
By the time we hit the execution button for the next line (which contains the query), database is timed out and it is returning empty list.
If anyone has any other logic for why this is happening please do share.
Solution 2:
After trying different solution, I have figured out that the problem described in the question arises when I execute it in "Debugging Mode" in pycharm. But on the other hand if I execute the code in "Run Mode" in pycharm , it returns the right expected output (a list with 11 elements):
[a,b,c,d,e,f,g,h,i,j,k]
Not sure about the exact reason for it but somehow the cursor was breaking somewhere when run in "Debugging Mode". If anyone describes the exact reason, It ll be highly appreciated.
Post a Comment for "Python Psycopg2 Cursor.fetchall() Returns Empty List But Cursor.rowcount Is > 1"