smbinterp/tools/mkpoints.py
Stephen Mardson McQuay 961b3b7b26 init
2009-12-27 10:48:27 -07:00

27 lines
538 B
Python
Executable File

#!/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()