从数据库加载 profiles
(db_path: str)
| 34 | |
| 35 | |
| 36 | def load_profiles(db_path: str) -> Dict[str, Dict[str, Any]]: |
| 37 | """从数据库加载 profiles""" |
| 38 | path = Path(db_path) |
| 39 | if not path.is_absolute(): |
| 40 | path = PROJECT_ROOT / db_path |
| 41 | |
| 42 | conn = sqlite3.connect(path) |
| 43 | profiles = conn.execute("SELECT user_id, profile_json, version FROM profiles").fetchall() |
| 44 | conn.close() |
| 45 | |
| 46 | result = {} |
| 47 | for row in profiles: |
| 48 | result[row[0]] = { |
| 49 | "profile": json.loads(row[1]), |
| 50 | "version": row[2], |
| 51 | } |
| 52 | |
| 53 | return result |
| 54 | |
| 55 | |
| 56 | def init_user_metadata( |