Method
__init__
(
self,
port: int,
host: str,
user: str,
password: str | None,
database: str | None,
require_ssl: bool,
)
Source from the content-addressed store, hash-verified
| 30 | """An API to the database under exploration.""" |
| 31 | |
| 32 | def __init__( |
| 33 | self, |
| 34 | port: int, |
| 35 | host: str, |
| 36 | user: str, |
| 37 | password: str | None, |
| 38 | database: str | None, |
| 39 | require_ssl: bool, |
| 40 | ) -> None: |
| 41 | logging.debug(f"Initialize Database with host={host} port={port}, user={user}") |
| 42 | |
| 43 | if require_ssl: |
| 44 | # verify_mode=ssl.CERT_REQUIRED is the default |
| 45 | ssl_context = ssl.create_default_context() |
| 46 | else: |
| 47 | ssl_context = None |
| 48 | |
| 49 | self.conn = pg8000.connect( |
| 50 | host=host, |
| 51 | port=port, |
| 52 | user=user, |
| 53 | password=password, |
| 54 | database=database, |
| 55 | ssl_context=ssl_context, |
| 56 | ) |
| 57 | self.conn.autocommit = True |
| 58 | |
| 59 | def close(self) -> None: |
| 60 | self.conn.close() |
Callers
nothing calls this directly
Tested by
no test coverage detected