| 40 | ) |
| 41 | |
| 42 | def save_request(self, req: dict): |
| 43 | with self._lock, self._conn: |
| 44 | self._conn.execute( |
| 45 | """INSERT INTO requests (id, data_type, status, source, priority, submit_time, complete_time, payload) |
| 46 | VALUES (?, ?, ?, ?, ?, ?, ?, ?) |
| 47 | ON CONFLICT(id) DO UPDATE SET |
| 48 | status=excluded.status, complete_time=excluded.complete_time, payload=excluded.payload""", |
| 49 | ( |
| 50 | req.get("id"), req.get("data_type"), req.get("status"), req.get("source"), |
| 51 | req.get("priority"), req.get("submit_time"), req.get("complete_time"), |
| 52 | json.dumps(req, ensure_ascii=False), |
| 53 | ), |
| 54 | ) |
| 55 | |
| 56 | def load_requests(self): |
| 57 | with self._lock: |