Skip to content

Commit 823ba33

Browse files
committed
update sql
1 parent 17a371f commit 823ba33

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

dictionary/sqlite/create_english_db_with_translation_and_ipa.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
''')
1919

2020
c.execute('CREATE INDEX IF NOT EXISTS idx_word ON words(word);')
21+
c.execute('delete from words;')
2122
c.execute("PRAGMA journal_mode=WAL")
2223

2324
# Insert data
2425
for word, details in data.items():
2526
c.execute('''
26-
INSERT INTO words (word, frequency, translation, ipa) VALUES (?, ?, ?, ?)
27+
INSERT INTO words (word, frequency, translation, ipa) VALUES (?,?,?,?)
2728
''', (word, details['frequency'], '|'.join(details['translation']), details['ipa']))
2829

2930
# Commit the changes and close the connection

dictionary/sqlite/query_english_db_with_translation_and_ipa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def query_words_by_prefix(prefix):
66
with sqlite3.connect('words_with_frequency_and_translation_and_ipa.sqlite3') as conn:
77
c = conn.cursor()
88
# The LIKE operator is case-insensitive in SQLite by default
9-
c.execute('SELECT * FROM words WHERE word LIKE ? ORDER BY frequency DESC limit 30', (prefix + '%',))
9+
c.execute('SELECT * FROM words WHERE word LIKE ? ORDER BY frequency DESC limit 10', (prefix + '%',))
1010
results = c.fetchall()
1111
# conn.close()
1212

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)