работает

This commit is contained in:
sergey 2024-07-11 21:01:46 +03:00
parent ca88bec514
commit 88f6524ef6
4 changed files with 15 additions and 13 deletions

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
services:
pg:
image: postgres
environment:
POSTGRES_DB: sipi
POSTGRES_USER: sys.sipidb
POSTGRES_PASSWORD: password
ports:
- "5432:5432"

2
sipi-app/.env-template Normal file
View File

@ -0,0 +1,2 @@
SIPI_CONFIG__DB__URL=postgresql+asyncpg://username:password@localhost:5432/dbname
SIPI_CONFIG__DB__ECHO=0

View File

@ -25,20 +25,13 @@ class DatabaseConfig(BaseModel):
pool_size: int = 50 pool_size: int = 50
max_overflow: int = 10 max_overflow: int = 10
naming_convention: dict[str, str] = {
"ix": "ix_%(column_0_label)s",
"uq": "uq_%(table_name)s_%(column_0_N_name)s",
"ck": "ck_%(table_name)s_%(constraint_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s",
}
class Settings(BaseSettings): class Settings(BaseSettings):
model_config = SettingsConfigDict( model_config = SettingsConfigDict(
env_file=(".env.template", ".env"), env_file=('.env-template', '.env'),
case_sensitive=False, case_sensitive=False,
env_nested_delimiter="__", env_nested_delimiter='__',
env_prefix="APP_CONFIG__", env_prefix='SIPI_CONFIG__',
) )
run: RunConfig = RunConfig() run: RunConfig = RunConfig()
api: ApiPrefix = ApiPrefix() api: ApiPrefix = ApiPrefix()
@ -46,3 +39,4 @@ class Settings(BaseSettings):
settings = Settings() settings = Settings()

View File

@ -10,10 +10,7 @@ from fastapi import FastAPI
@asynccontextmanager @asynccontextmanager
async def lifespan(app: FastAPI): async def lifespan(app: FastAPI):
#startap
yield yield
#shutdown
print('dispose engine')
await db_helper.dispose() await db_helper.dispose()
main_app = FastAPI( main_app = FastAPI(