This commit is contained in:
Waylon Walker 2023-06-14 07:43:55 -05:00
parent 347418ee3f
commit b8a9ea0f17
6 changed files with 63 additions and 18 deletions

View file

@ -2,7 +2,7 @@ from contextvars import ContextVar
from typing import TYPE_CHECKING
from fastapi import Depends
from pydantic import BaseModel, BaseSettings
from pydantic import BaseModel, BaseSettings, validator
from sqlalchemy import create_engine
from sqlmodel import SQLModel, Session
@ -61,6 +61,12 @@ class Config(BaseSettings):
env_nested_delimiter = "__"
env_file = ".env", ".env.dev", ".env.qa", ".env.prod"
@validator("database_url")
def validate_database_url(cls, v: str) -> str:
if v.startswith("postgres://"):
return v.replace("postgres://", "postgresql+psycopg2://")
return v
@property
def database(self) -> Database:
return get_database(config=self)