set sqlite file path relative to config path if possible

This commit is contained in:
Izalia Mae 2024-01-22 06:50:31 -05:00
parent 9cc79aa79a
commit 57d7d25743
2 changed files with 4 additions and 1 deletions

View file

@ -57,6 +57,9 @@ class Config:
@property
def sqlite_path(self) -> Path:
if not os.path.isabs(self.sq_path):
return self.path.parent.joinpath(self.sq_path).resolve()
return Path(self.sq_path).expanduser().resolve()

View file

@ -18,7 +18,7 @@ if typing.TYPE_CHECKING:
def get_database(config: Config, migrate: Optional[bool] = True) -> tinysql.Database:
if config.db_type == "sqlite":
db = tinysql.Database.sqlite(config.sq_path, connection_class = Connection)
db = tinysql.Database.sqlite(config.sqlite_path, connection_class = Connection)
elif config.db_type == "postgres":
db = tinysql.Database.postgres(