Refactored configuration system

This commit is contained in:
th3r00t
2022-12-17 19:29:17 -05:00
parent 0d55a4e9f1
commit 0eaa19009f
7 changed files with 206 additions and 205 deletions

View File

@@ -49,12 +49,7 @@ class Storage:
str : sqlalchemy Connection String
"""
if self.config.db_engine == "sqlite":
if os.path.exists(f"{self.config.root}/pyshelf.db"):
return f"sqlite:////{self.config.root}/pyshelf.db"
else:
sqlite_file = open(f'{self.config.root}/pyshelf.db', 'w')
sqlite_file.close()
return f"sqlite://{self.config.root}/pyshelf.db"
return f"sqlite:////{self.config.root}/pyshelf.db"
elif self.config.db_engine == "psql":
return f"postgresql://{self.user}:{self.password}\
@{self.db_host}:{self.db_port}/{self.sql}"