ニジカ AI 共通サービス
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

  1. from __future__ import annotations
  2. import os
  3. from typing import TypedDict
  4. from eloquent import DatabaseManager, Model # type: ignore
  5. CONFIG: DBConfig = { 'default': 'nico', 'connections': {
  6. 'ai': { 'driver': 'mysql',
  7. 'host': 'localhost',
  8. 'database': 'nizika_ai',
  9. 'user': os.environ['MYSQL_USER'],
  10. 'password': os.environ['MYSQL_PASS'],
  11. 'prefix': '' },
  12. 'nico': { 'driver': 'mysql',
  13. 'host': 'localhost',
  14. 'database': 'nizika_nico',
  15. 'user': os.environ['MYSQL_USER'],
  16. 'password': os.environ['MYSQL_PASS'],
  17. 'prefix': '' } } }
  18. DB = DatabaseManager (CONFIG)
  19. Model.set_connection_resolver (DB)
  20. class DBConfig (TypedDict):
  21. default: str
  22. connections: dict[str, DBConnection]
  23. class DBConnection (TypedDict):
  24. driver: str
  25. host: str
  26. database: str
  27. user: str
  28. password: str
  29. prefix: str