It might be still useful to access the cursor state (e.g. rowcount, the
status message) after the cursor is closed, especially if the block
syntax is used.
Memory use is not really a problem: memory is cleared on GC anyway and
most functions using a cursor don't rely on the memory freed between
close() and the end of the function.
def _close(self) -> None:
self._closed = True
- # however keep the query available, which can be useful for debugging
- # in case of errors
- pgq = self._pgq
- self._reset()
- self._pgq = pgq
AnyCursor = BaseCursor[Any, Row]
cur.execute("select 1")
assert cur.status == cur.ExecStatus.TUPLES_OK
cur.close()
- assert cur.status is None
+ assert cur.status == cur.ExecStatus.TUPLES_OK
def test_execute_many_results(conn):
assert cur.rowcount == 42
cur.close()
- assert cur.rowcount == -1
+ assert cur.rowcount == 42
def test_rownumber(conn):
await cur.execute("select 1")
assert cur.status == cur.ExecStatus.TUPLES_OK
await cur.close()
- assert cur.status is None
+ assert cur.status == cur.ExecStatus.TUPLES_OK
async def test_execute_many_results(aconn):
assert cur.rowcount == 42
await cur.close()
- assert cur.rowcount == -1
+ assert cur.rowcount == 42
async def test_rownumber(aconn):