Skip to content

Instantly share code, notes, and snippets.

@lopesivan
Forked from danielrmeyer/generate.py
Created April 11, 2022 22:47
Show Gist options
  • Save lopesivan/f5df37fe2b61ddb674b3fe247416e056 to your computer and use it in GitHub Desktop.
Save lopesivan/f5df37fe2b61ddb674b3fe247416e056 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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment