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
dd56ba5f
Commit
dd56ba5f
authored
11 months ago
by
Bastien Abadie
Committed by
Erwan Rouchet
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Ensure django database wrappers always have a connection before creating a cursor
parent
22ca1d12
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2272
Ensure django database wrappers always have a connection before creating a cursor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/documents/export/__init__.py
+7
-1
7 additions, 1 deletion
arkindex/documents/export/__init__.py
with
7 additions
and
1 deletion
arkindex/documents/export/__init__.py
+
7
−
1
View file @
dd56ba5f
...
...
@@ -51,7 +51,13 @@ def run_pg_query(query, source_db):
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
[
source_db
].
create_cursor
(
name
=
str
(
uuid
.
uuid4
()))
as
pg_cursor
:
db
=
connections
[
source_db
]
# Make sure a connection is open and available for export databases
if
source_db
!=
"
default
"
and
db
.
connection
is
None
:
db
.
connect
()
with
db
.
create_cursor
(
name
=
str
(
uuid
.
uuid4
()))
as
pg_cursor
:
pg_cursor
.
itersize
=
BATCH_SIZE
pg_cursor
.
execute
(
query
)
...
...
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