Fix the Database no being put on the right path according with the config.toml

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-07-16 16:39:31 -03:00
parent bdaa37e355
commit 967c7e4ce6
4 changed files with 24 additions and 10 deletions
+10 -3
View File
@@ -12,10 +12,17 @@ Base = declarative_base()
class Database:
def __init__(self,config_manager:ConfigManager):
db_path = config_manager.database_url
def __init__(self, config_manager: ConfigManager):
self.db_path = config_manager.database_url
# Garantir que o diretório existe
db_dir = os.path.dirname(self.db_path)
if not os.path.exists(db_dir):
os.makedirs(db_dir, exist_ok=True)
self.engine = create_engine(
f"sqlite:///{config_manager.database_url}",
f"sqlite:///{self.db_path}",
echo=False,
connect_args={"check_same_thread": False},
)