Skip to content

Commit

Permalink
fix sqlite db issue: copy db to user folder
Browse files Browse the repository at this point in the history
  • Loading branch information
dongyuwei committed Oct 20, 2024
1 parent 1f32d68 commit 54e3338
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion python/input_methods/hallelujah/ime_hallelujah.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyphonetics import FuzzySoundex
import textdistance
import os
import shutil
from loguru import logger
import cProfile

Expand All @@ -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)
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.10
1.3.11

0 comments on commit 54e3338

Please sign in to comment.