Add support to force import keys

This commit is contained in:
2024-03-13 18:10:09 +08:00
parent c37abe2f3f
commit b62571f711
5 changed files with 23 additions and 7 deletions

8
db.py
View File

@@ -1,6 +1,6 @@
import sqlite3
from semver import Version
from typing import Optional, Set, List
from typing import Dict, Optional, List
VERSION_TABLE = '''CREATE TABLE version (
@@ -67,9 +67,9 @@ class CwmDb:
self._db.execute('INSERT OR REPLACE INTO key VALUES (?, ?, ?);', [
chapter_id, user_id, key])
def get_all_keys_as_origin(self) -> Set[str]:
cur = self._db.execute('SELECT chapter_id, user_id FROM key;')
return {f'{i[0]}{i[1]}' for i in cur}
def get_all_keys_as_origin(self) -> Dict[str, str]:
cur = self._db.execute('SELECT chapter_id, user_id, key FROM key;')
return {f'{i[0]}{i[1]}': i[2] for i in cur}
def get_key(self, chapter_id: int) -> List[str]:
cur = self._db.execute('SELECT key FROM key WHERE chapter_id = ?;', [