- Notifications
You must be signed in to change notification settings - Fork46
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
dsn: str | ||
commit_on_exit: bool = True | ||
debug: bool = False | ||
use_queue: bool = False |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
This PR tries toresolve#340 by completely refactoring the PgstacDb class and its usage by other classes/methods