[add]: Database connection and migrations

This commit is contained in:
VivianDee
2025-03-28 08:38:32 +01:00
parent 3054b7240e
commit 65efe0573a
21 changed files with 431 additions and 19 deletions
+20 -1
View File
@@ -5,6 +5,11 @@ from flask_cors import CORS
from app.config import Config
from app.api.routes import api
from app.errors import register_error_handlers
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
db = SQLAlchemy()
migrate = Migrate()
def create_app():
""" Factory function to create a Flask app instance """
@@ -31,7 +36,21 @@ def create_app():
# Error Handlers
register_error_handlers(app)
import logging
from sqlalchemy import create_engine
# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Log the database URI
logger.info(f"Database URI: {app.config['SQLALCHEMY_DATABASE_URI']}")
# Database and Migrations
db.init_app(app)
migrate.init_app(app, db)
return app