Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
database-lib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Global Dynamic Exposure
Libraries
database-lib
Merge requests
!9
You need to sign in or sign up before continuing.
Resolve "Implement server-side cursors"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Implement server-side cursors"
9-implement-server-side-cursors
into
main
Overview
4
Commits
1
Pipelines
11
Changes
1
Merged
Laurens Oostwegel
requested to merge
9-implement-server-side-cursors
into
main
2 years ago
Overview
4
Commits
1
Pipelines
11
Changes
1
Expand
Closes
#9 (closed)
\approve
@gislars
@ds
Edited
2 years ago
by
Laurens Oostwegel
0
0
Merge request reports
Compare
main
version 9
744fdb35
2 years ago
version 8
46613df5
2 years ago
version 7
3f9eda3e
2 years ago
version 6
1269983a
2 years ago
version 5
b6e4ceab
2 years ago
version 4
ffa00375
2 years ago
version 3
c6037069
2 years ago
version 2
ac7ea579
2 years ago
version 1
e6ca59cf
2 years ago
main (base)
and
latest version
latest version
1b14e0be
1 commit,
2 years ago
version 9
744fdb35
4 commits,
2 years ago
version 8
46613df5
3 commits,
2 years ago
version 7
3f9eda3e
2 commits,
2 years ago
version 6
1269983a
1 commit,
2 years ago
version 5
b6e4ceab
4 commits,
2 years ago
version 4
ffa00375
3 commits,
2 years ago
version 3
c6037069
2 commits,
2 years ago
version 2
ac7ea579
1 commit,
2 years ago
version 1
e6ca59cf
1 commit,
2 years ago
1 file
+
22
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
databaselib/database.py
+
22
−
0
Options
@@ -21,6 +21,7 @@ import logging
import
sqlite3
import
psycopg2
from
packaging
import
version
from
uuid
import
uuid4
logger
=
logging
.
getLogger
()
@@ -245,3 +246,24 @@ class PostGISDatabase(AbstractDatabase):
self
.
cursor
=
self
.
connection
.
cursor
()
except
Exception
as
e
:
logger
.
exception
(
e
)
def
execute_server_side
(
self
,
sql_statement
:
str
,
itersize
:
int
=
None
):
"""
Execute an SQL statement with a server-side cursor.
Args:
sql_statement (str):
SQL statement to be executed.
itersize (int):
Number of rows fetched from the server at one call.
Returns:
Generator object of the query result.
"""
with
self
.
connection
.
cursor
(
name
=
f
"
{
uuid4
()
}
"
)
as
cursor
:
if
itersize
is
not
None
:
cursor
.
itersize
=
itersize
cursor
.
execute
(
sql_statement
)
for
result
in
cursor
:
yield
result
Loading