From 54e3338ea5a24e0bf6c17c4c05223714aaa616a6 Mon Sep 17 00:00:00 2001 From: Dong Yuwei Date: Sun, 20 Oct 2024 18:02:47 +0800 Subject: [PATCH] fix sqlite db issue: copy db to user folder --- python/input_methods/hallelujah/ime_hallelujah.py | 8 +++++++- version.txt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/python/input_methods/hallelujah/ime_hallelujah.py b/python/input_methods/hallelujah/ime_hallelujah.py index 96b82999..83353768 100644 --- a/python/input_methods/hallelujah/ime_hallelujah.py +++ b/python/input_methods/hallelujah/ime_hallelujah.py @@ -9,6 +9,7 @@ from pyphonetics import FuzzySoundex import textdistance import os +import shutil from loguru import logger import cProfile @@ -19,6 +20,11 @@ os.makedirs(log_dir) logger.add(log_file) +init_db_path = os.path.join(os.path.join(os.path.dirname(__file__), "dict"), 'words_with_frequency_and_translation_and_ipa.sqlite3') +db_path = r"{}\AppData\Local\PIME\PIME-hallelujah.sqlite3".format(user_folder) +# we must copy the sqlite db to user folder with read && write permission(wal,shm) +shutil.copy2(init_db_path, db_path) + fuzzySoundex = FuzzySoundex() def damerau_levenshtein_distance(word, input_word): return textdistance.damerau_levenshtein(word, input_word) @@ -44,7 +50,7 @@ def init(self): self.spellchecker = Speller() def init_db_connection(self): - with sqlite3.connect(os.path.join(self.dictPath, 'words_with_frequency_and_translation_and_ipa.sqlite3')) as conn: + with sqlite3.connect(db_path) as conn: self.db_connection = conn def loadPinyinData(self): diff --git a/version.txt b/version.txt index 0c00f610..17e63e7a 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.3.10 +1.3.11