MCPcopy
hub / github.com/django/django / cursor_iter

Function cursor_iter

django/db/models/sql/compiler.py:2257–2266  ·  view source on GitHub ↗

Yield blocks of rows from a cursor and ensure the cursor is closed when done.

(cursor, sentinel, col_count, itersize)

Source from the content-addressed store, hash-verified

2255
2256
2257def cursor_iter(cursor, sentinel, col_count, itersize):
2258 """
2259 Yield blocks of rows from a cursor and ensure the cursor is closed when
2260 done.
2261 """
2262 try:
2263 for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
2264 yield rows if col_count is None else [r[:col_count] for r in rows]
2265 finally:
2266 cursor.close()

Callers 1

execute_sqlMethod · 0.85

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected