Created
October 19, 2013 02:36
-
-
Save darkblue-b/7051084 to your computer and use it in GitHub Desktop.
sample data with a certain distribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
import random | |
conn = psycopg2.connect( 'dbname=ta_test' ) | |
curs = conn.cursor() | |
tSQL_create0 = ''' | |
drop table if exists tta cascade; | |
create table tta ( tta_item integer, pkey serial); | |
''' | |
curs.execute(tSQL_create0) | |
for tInd in xrange(100000): | |
tD = int(random.random() * 12) | |
if tD > 3: | |
tIters = 1 | |
else: | |
tIters = tD + 2 | |
for x in xrange(tIters): | |
curs.execute( 'INSERT into tta (tta_item) VALUES ({0})'.format(tInd) ) | |
if tInd % 10000: conn.commit() | |
conn.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment