Skip to content

Instantly share code, notes, and snippets.

@gamefreak
Created February 14, 2012 02:21
Show Gist options
  • Save gamefreak/1822611 to your computer and use it in GitHub Desktop.
Save gamefreak/1822611 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
from os import system as s
import sqlite3,datetime
s('rm -f ./test.sqlite');
conn = sqlite3.connect('test.sqlite');
c = conn.cursor();
c.execute('CREATE TABLE foo(bar STRING PRIMARY KEY, baz STRING,bin);');
c.execute('CREATE INDEX index_bar ON foo(bar);');
c.execute('CREATE INDEX index_baz ON foo(baz);');
c.execute('CREATE INDEX index_bin ON foo(bin);');
conn.commit()
prev = datetime.datetime.now()
for i in range(1000000):
if (i%10000 == 0):
curr=datetime.datetime.now()
print "%08d %06d" % (i, (curr-prev).microseconds)
# print "%06d" % (i, (curr-prev).microseconds)
prev = curr
conn.commit();
c.execute('INSERT INTO foo(bar,baz,bin) VALUES(?,?,?);',(i,'a'+str(1000000-i)+'b',i%33333))
conn.commit()
conn.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment