Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
9ad2e0ab
Verified
Commit
9ad2e0ab
authored
3 years ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Use a server-side cursor
parent
73fbf1ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/documents/export/__init__.py
+4
-3
4 additions, 3 deletions
arkindex/documents/export/__init__.py
with
4 additions
and
3 deletions
arkindex/documents/export/__init__.py
+
4
−
3
View file @
9ad2e0ab
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment