File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,7 @@ class PostgresSettings(DatabaseSettings):
3131 POSTGRES_SERVER : str = "localhost"
3232 POSTGRES_PORT : int = 5432
3333 POSTGRES_DB : str = "postgres"
34- POSTGRES_SYNC_PREFIX : str = "postgresql://"
3534 POSTGRES_ASYNC_PREFIX : str = "postgresql+asyncpg://"
36- POSTGRES_URL : str | None = None
3735
3836 @computed_field # type: ignore[prop-decorator]
3937 @property
@@ -42,6 +40,11 @@ def POSTGRES_URI(self) -> str:
4240 location = f"{ self .POSTGRES_SERVER } :{ self .POSTGRES_PORT } /{ self .POSTGRES_DB } "
4341 return f"{ credentials } @{ location } "
4442
43+ @computed_field # type: ignore[prop-decorator]
44+ @property
45+ def POSTGRES_URL (self ) -> str :
46+ return f"{ self .POSTGRES_ASYNC_PREFIX } { self .POSTGRES_URI } "
47+
4548
4649class FirstUserSettings (BaseSettings ):
4750 ADMIN_NAME : str = "admin"
Original file line number Diff line number Diff line change @@ -11,9 +11,7 @@ class Base(DeclarativeBase, MappedAsDataclass):
1111 pass
1212
1313
14- DATABASE_URI = settings .POSTGRES_URI
15- DATABASE_PREFIX = settings .POSTGRES_ASYNC_PREFIX
16- DATABASE_URL = f"{ DATABASE_PREFIX } { DATABASE_URI } "
14+ DATABASE_URL = settings .POSTGRES_URL
1715
1816
1917async_engine = create_async_engine (DATABASE_URL , echo = False , future = True )
Original file line number Diff line number Diff line change 1313from src .app .core .config import settings
1414from src .app .main import app
1515
16- DATABASE_URI = settings .POSTGRES_URI
17- DATABASE_PREFIX = settings .POSTGRES_SYNC_PREFIX
16+ DATABASE_URL = settings .POSTGRES_URL
1817
19- sync_engine = create_engine (DATABASE_PREFIX + DATABASE_URI )
18+
19+ sync_engine = create_engine (DATABASE_URL )
2020local_session = sessionmaker (autocommit = False , autoflush = False , bind = sync_engine )
2121
2222
You can’t perform that action at this time.
0 commit comments