Skip to content

Instantly share code, notes, and snippets.

@RyanGWU82
Created September 13, 2019 21:29
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 RyanGWU82/274c6db8c346c020da502a6cb045e944 to your computer and use it in GitHub Desktop.
Save RyanGWU82/274c6db8c346c020da502a6cb045e944 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3.6
from datetime import datetime
import random
import sqlite3
import time
import os
def main():
if os.path.exists("example.db"):
os.remove("example.db")
conn = sqlite3.connect('example.db')
try:
c = conn.cursor()
c.execute("CREATE TABLE data(foo number)")
conn.commit()
del c
except Exception as e:
pass
while True:
time.sleep(random.randrange(50, 200) / 1000.0)
c = conn.cursor()
c.execute("DELETE FROM data")
print(f"{time.time()}: DELETE FROM data")
# time.sleep(random.randrange(50, 200) / 1000.0)
ts = time.time()
c.execute("INSERT INTO data(foo) VALUES(?)", [ts])
print(f"{time.time()}: INSERT INTO data(foo) VALUES({ts})")
# time.sleep(random.randrange(50, 200) / 1000.0)
conn.commit()
print(f"{time.time()}: COMMIT")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment