import threading
from myspellchecker.providers.connection_pool import ConnectionPool
from myspellchecker.core.config.validation_configs import ConnectionPoolConfig
pool_config = ConnectionPoolConfig(min_size=2, max_size=10)
pool = ConnectionPool("/path/to/db.sqlite", pool_config=pool_config)
def worker(word):
with pool.checkout() as conn:
cursor = conn.cursor()
cursor.execute("SELECT * FROM words WHERE word = ?", (word,))
return cursor.fetchone()
# Safe to use from multiple threads
threads = []
for word in ["မြန်မာ", "နိုင်ငံ", "ကျောင်း"]:
t = threading.Thread(target=worker, args=(word,))
threads.append(t)
t.start()
for t in threads:
t.join()