Created
November 11, 2015 06:06
-
-
Save dreampuf/bda61a907142af0ffce0 to your computer and use it in GitHub Desktop.
Sqlite WAL test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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