- implement postgres connection pool

- adapt current sqlalchemy based methods to produce raw sql
This commit is contained in:
Jakub Miazek
2024-05-11 16:03:33 +02:00
parent 40984ed7e3
commit 514eea7231
5 changed files with 63 additions and 19 deletions

View File

@@ -70,5 +70,29 @@ class Settings(BaseSettings):
path=self.POSTGRES_DB,
)
@computed_field
@property
def postgres_url(self) -> PostgresDsn:
"""
This is a computed field that generates a PostgresDsn URL
The URL is built using the MultiHostUrl.build method, which takes the following parameters:
- scheme: The scheme of the URL. In this case, it is "postgres".
- username: The username for the Postgres database, retrieved from the POSTGRES_USER environment variable.
- password: The password for the Postgres database, retrieved from the POSTGRES_PASSWORD environment variable.
- host: The host of the Postgres database, retrieved from the POSTGRES_HOST environment variable.
- path: The path of the Postgres database, retrieved from the POSTGRES_DB environment variable.
Returns:
PostgresDsn: The constructed PostgresDsn URL.
"""
return MultiHostUrl.build(
scheme="postgres",
username=self.POSTGRES_USER,
password=self.POSTGRES_PASSWORD,
host=self.POSTGRES_HOST,
path=self.POSTGRES_DB,
)
settings = Settings()