[add]: Database config

This commit is contained in:
VivianDee
2025-09-09 12:22:05 +01:00
parent ebe40cda19
commit 239d19fbac
3 changed files with 138 additions and 3 deletions
+2 -3
View File
@@ -7,7 +7,7 @@ import pandas as pd
from datetime import datetime
import logging
import os
from app.config import DB_CONFIG, TABLE_NAME
from app.config import SQLALCHEMY_DATABASE_URI, TABLE_NAME
from app.utils.logger import logger
class DataLoader:
@@ -20,8 +20,7 @@ class DataLoader:
"""Establish database connection."""
try:
logger.info("Attempting to connect to database...")
DATABASE_URL = f"postgresql://{DB_CONFIG['user']}:{DB_CONFIG['password']}@{DB_CONFIG['host']}:{DB_CONFIG['port']}/{DB_CONFIG['name']}"
self.engine = create_engine(DATABASE_URL)
self.engine = create_engine(SQLALCHEMY_DATABASE_URI)
with self.engine.connect() as conn:
# First check if table exists
check_table = text(f"SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = '{TABLE_NAME}')")