Results of my master's thesis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mkpoints.py 538B

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