Skip to content

Instantly share code, notes, and snippets.

@danielrmeyer
Last active April 11, 2022 22:47
Show Gist options
  • Save danielrmeyer/bfa415256502471d1512f2155e76adc2 to your computer and use it in GitHub Desktop.
Save danielrmeyer/bfa415256502471d1512f2155e76adc2 to your computer and use it in GitHub Desktop.
import sqlite3
import os
from itertools import cycle, product
DB_FILE = "data.sqlite3"
num_rows = 100000000
elements = cycle(product(["name1", "name2", "name3"], [1,2,3]))
conn = sqlite3.connect(DB_FILE)
curs = conn.cursor()
curs.execute("CREATE TABLE test (name string, val integer);")
curs.executemany("INSERT INTO test (name, val) VALUES (?, ?)",
[next(elements) for row in range(num_rows)])
conn.commit()
curs.execute("select count(*) from test")
@danielrmeyer
Copy link
Author

Yep, your right. Data is computed twice. fixing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment