Skip to content

Instantly share code, notes, and snippets.

View Directory's full-sized avatar

Directory Directory

View GitHub Profile
@Directory
Directory / multi_threaded_memory_db.py
Created November 3, 2019 07:02
This is an example demo of how I was able to pass an sqlite3 database in memory between threads.
import sqlite3
from threading import Thread
import time
conn = sqlite3.connect("file::memory:?cache=shared", uri=True, check_same_thread=False)
conn.execute("PRAGMA journal_mode=MEMORY")
c = conn.cursor()
# s = time.time()
c.execute('CREATE TABLE test (test TEXT, test2 TEXT)')