Skip to content

Instantly share code, notes, and snippets.

@dreampuf
Created November 11, 2015 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreampuf/bda61a907142af0ffce0 to your computer and use it in GitHub Desktop.
Save dreampuf/bda61a907142af0ffce0 to your computer and use it in GitHub Desktop.
Sqlite WAL test
import time
from playhouse.sqlite_ext import SqliteExtDatabase
sqlite_db = SqliteExtDatabase('my_app.db', journal_mode="WAL", autocommit=False)
with sqlite_db.transaction() as cursor:
cursor = sqlite_db.execute_sql("""CREATE TABLE server_status (
id INTEGER PRIMARY KEY,
time_created INT);""")
assert cursor.rowcount == -1
n = 10000000
bulk = range(n)
SQL = "INSERT INTO server_status(time_created) VALUES " + ",".join(map(lambda x: "(%d)" % x, bulk))
while True:
with sqlite_db.transaction() as cursor:
ret = sqlite_db.execute_sql(SQL)
assert ret.rowcount == n
time.sleep(.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment