#NEWLINE# def create_sample_data( session ) : #NEWLINE# #INDENT# rnd = random . WichmannHill ( 1 ) #NEWLINE# account_1234 = Account ( id = 1234 , name = 'user1234' , apikey = '26ec5efff4a6' ) #NEWLINE# session . add ( account_1234 ) #NEWLINE# account_1235 = Account ( id = 1235 , name = 'lukz' , mbuser = 'lukz' , apikey = '2112c535e9e6' , is_admin = True ) #NEWLINE# session . add ( account_1235 ) #NEWLINE# application_1234 = Application ( account = account_1234 , name = 'Test App' , version = '1.0' , apikey = '617f98b2d7cc' ) #NEWLINE# session . add ( application_1234 ) #NEWLINE# unflushed = 0 #NEWLINE# dt = datetime . datetime ( 2014 , 1 , 2 ) #NEWLINE# while ( dt < datetime . datetime . now ( ) ) : #NEWLINE# #INDENT# obj = StatsLookups ( date = dt . date ( ) , hour = dt . hour , application = application_1234 ) #NEWLINE# obj . count_nohits = rnd . randint ( 0 , 1000 ) #NEWLINE# obj . count_hits = rnd . randint ( 0 , 10000 ) #NEWLINE# session . add ( obj ) #NEWLINE# dt += datetime . timedelta ( hours = 1 ) #NEWLINE# unflushed += 1 #NEWLINE# if ( unflushed > 100 ) : #NEWLINE# #INDENT# session . flush ( ) #NEWLINE# unflushed = 0 #NEWLINE# #UNINDENT# #UNINDENT# application_1235 = Application ( account = account_1235 , name = 'Test App 2' , version = '0.2' , apikey = 'c24d2e31d8db' ) #NEWLINE# session . add ( application_1235 ) #NEWLINE# unflushed = 0 #NEWLINE# dt = datetime . datetime ( 2015 , 2 , 3 ) #NEWLINE# while ( dt < datetime . datetime . now ( ) ) : #NEWLINE# #INDENT# obj = StatsLookups ( date = dt . date ( ) , hour = dt . hour , application = application_1235 ) #NEWLINE# obj . count_nohits = rnd . randint ( 0 , 200 ) #NEWLINE# obj . count_hits = rnd . randint ( 0 , 1000 ) #NEWLINE# session . add ( obj ) #NEWLINE# dt += datetime . timedelta ( hours = 1 ) #NEWLINE# unflushed += 1 #NEWLINE# if ( unflushed > 100 ) : #NEWLINE# #INDENT# session . flush ( ) #NEWLINE# unflushed = 0 #NEWLINE# #UNINDENT# #UNINDENT# session . commit ( )