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}fuware.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
