import os
from sqlmodel import SQLModel, create_engine, Session
from dotenv import load_dotenv

load_dotenv()

DATABASE_URL = os.getenv("DATABASE_URL")

if not DATABASE_URL:
    raise ValueError(
        "DATABASE_URL environment variable is not set. "
        "Please set it to your database connection string, e.g., "
        "mysql+pymysql://user:password@localhost:3306/dbname"
    )

# MySQL-specific engine configuration
engine = create_engine(
    DATABASE_URL,
    echo=False,
    pool_pre_ping=True,  # Verify connections before using them
    pool_recycle=3600    # Recycle connections after 1 hour
)

def init_db():
    """Database initialization - table creation disabled.
    Tables should be created manually in MySQL."""
    pass  # Tables managed manually in MySQL