Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor pgstacDb class#375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
vincentsarago wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromrefactor/pypgstac-PgstacDB

Conversation

vincentsarago
Copy link
Member

This PR tries toresolve#340 by completely refactoring the PgstacDb class and its usage by other classes/methods

dsn: str
commit_on_exit: bool = True
debug: bool = False
use_queue: bool = False
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

removed possibility to pass aConnection object which adds to much complexity

if self.pool is not None:
self.pool.close()
if self._pool is not None:
self._pool.close()
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

only closepool if we created it


@contextlib.contextmanager
def connect(self) -> Connection:
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

connect() should be use in a context manager

withPgstacDb(dsn=...)asdb:withdb.connect()asconn:         ...


conn: Connection = None
try:
conn = pool.getconn()
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

we could also switch to

withpool.connection()asconn:

@@ -28,7 +29,9 @@ def __init__(
sys.exit(0)

self.dsn = dsn
self._db = PgstacDB(dsn=dsn, debug=debug, use_queue=usequeue)
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

decided not to hold a PgSTACDb object inself but instead create it within each subcommand

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Database connections are never closed
1 participant
@vincentsarago

[8]ページ先頭

©2009-2025 Movatter.jp