#!/usr/bin/python import sqlite3 import sys, os import numpy as np output_file = 'points.db' if os.path.exists(output_file): print "found old db, erasing" os.unlink(output_file) create = 'CREATE TABLE points (point_id integer primary key, x float, y float)' sqconn = sqlite3.connect(output_file) sqc = sqconn.cursor() sqc.execute(create) for i in xrange(int(1e6)): rx = np.random.rand() * 2 - 1 ry = np.random.rand() * 2 - 1 sqc.execute('INSERT INTO points VALUES (NULL, ?, ?)', (rx, ry)) sqconn.commit() sqconn.close()