Created
September 13, 2019 21:29
-
-
Save RyanGWU82/274c6db8c346c020da502a6cb045e944 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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