lot_manager/db/base.py

21 lines
559 B
Python
Raw Normal View History

2023-12-02 10:53:31 +08:00
import os
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
from sqlalchemy.orm import sessionmaker
import json
2023-12-09 15:53:56 +08:00
2023-12-02 11:56:11 +08:00
KB_ROOT_PATH = "/home/pi/"
2023-12-02 10:53:31 +08:00
DB_ROOT_PATH = os.path.join(KB_ROOT_PATH, "lot_data.db")
SQLALCHEMY_DATABASE_URI = f"sqlite:///{DB_ROOT_PATH}"
engine = create_engine(
SQLALCHEMY_DATABASE_URI,
json_serializer=lambda obj: json.dumps(obj, ensure_ascii=False),
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base: DeclarativeMeta = declarative_base()