mirror of
https://github.com/hongguang1994/SimNexus.git
synced 2026-11-23 05:47:31 +08:00
支持多 USB 4G 模块管理、实时信号监控、短信收发及定时自动发送任务。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
491 B
Python
22 lines
491 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
|
from app.core.config import settings
|
|
|
|
engine = create_engine(
|
|
settings.DATABASE_URL,
|
|
connect_args={"check_same_thread": False} if "sqlite" in settings.DATABASE_URL else {},
|
|
)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|