mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
23 lines
485 B
Python
23 lines
485 B
Python
import os
|
|
from functools import lru_cache
|
|
|
|
from pydantic import BaseSettings, PostgresDsn
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
asyncpg_url: PostgresDsn = PostgresDsn.build(
|
|
scheme="postgresql+asyncpg",
|
|
user=os.getenv("SQL_USER"),
|
|
password=os.getenv("POSTGRES_PASSWORD"),
|
|
host=os.getenv("SQL_HOST"),
|
|
port="5432",
|
|
path=f"/{os.getenv('SQL_DB') or ''}",
|
|
)
|
|
|
|
|
|
@lru_cache
|
|
def get_settings():
|
|
return Settings()
|
|
|
|
settings = get_settings()
|