build settings

This commit is contained in:
2024-04-26 15:18:47 +00:00
parent b71f0054a0
commit ab1e864478
10 changed files with 200 additions and 19 deletions

View File

@ -0,0 +1,28 @@
from abc import ABC, abstractmethod
from pathlib import Path
from pydantic import BaseModel
class AbstractDBProvider(ABC):
@property
@abstractmethod
def db_url(self) -> str: ...
@property
@abstractmethod
def db_url_public(self) -> str: ...
class SQLiteProvider(AbstractDBProvider, BaseModel):
data_dir: Path
prefix: str = ""
@property
def db_path(self):
return self.data_dir / f"{self.prefix}mealie.db"
@property
def db_url(self) -> str:
return f"sqlite:///{str(self.db_path.absolute())}"
@property
def db_url_public(self) -> str:
return self.db_url