Skip to content
Snippets Groups Projects
Verified Commit 9ad2e0ab authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Use a server-side cursor

parent 73fbf1ee
No related branches found
No related tags found
No related merge requests found
......@@ -34,10 +34,11 @@ EXPORT_QUERIES = [
def run_pg_query(query):
"""
Run a single Postgresql query and split the results
into chunks
Run a single Postgresql query and split the results into chunks.
When a name is given to a cursor, psycopg2 uses a server-side cursor; we just use a random string as a name.
"""
with connections['default'].cursor() as pg_cursor:
with connections['default'].create_cursor(name=str(uuid.uuid4())) as pg_cursor:
pg_cursor.itersize = BATCH_SIZE
pg_cursor.execute(query)
while True:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment