File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22from sqlalchemy .ext .declarative import declarative_base
33from sqlalchemy .orm import sessionmaker
44import datetime
5+ import os
56
6- # SQLite for development, easy to switch to PostgreSQL later
7- DATABASE_URL = "sqlite:///./pyscure.db"
7+ # Fix #2: Read DATABASE_URL from environment variable (set in docker-compose.yml)
8+ # Falls back to security_logs.db for local development
9+ DATABASE_URL = os .getenv ("DATABASE_URL" , "sqlite:///./security_logs.db" )
810
9- engine = create_engine (DATABASE_URL , connect_args = {"check_same_thread" : False })
11+ # SQLite requires check_same_thread=False; ignored safely for other DBs
12+ connect_args = {"check_same_thread" : False } if DATABASE_URL .startswith ("sqlite" ) else {}
13+
14+ engine = create_engine (DATABASE_URL , connect_args = connect_args )
1015SessionLocal = sessionmaker (autocommit = False , autoflush = False , bind = engine )
1116
1217Base = declarative_base ()
You can’t perform that action at this time.
0 commit comments