db.py 434 B

12345678910111213141516171819
  1. from peewee import *
  2. from config import SRC_LOG_LEVELS, DATA_DIR
  3. import os
  4. import logging
  5. log = logging.getLogger(__name__)
  6. log.setLevel(SRC_LOG_LEVELS["DB"])
  7. # Check if the file exists
  8. if os.path.exists(f"{DATA_DIR}/ollama.db"):
  9. # Rename the file
  10. os.rename(f"{DATA_DIR}/ollama.db", f"{DATA_DIR}/webui.db")
  11. log.info("File renamed successfully.")
  12. else:
  13. pass
  14. DB = SqliteDatabase(f"{DATA_DIR}/webui.db")
  15. DB.connect()