affinity_search/ga_addrequests.py
def addrows(config,host,db,password):
    '''add rows from fname into database, starting at row start'''
    
    conn = MySQLdb.connect (host = host,user = "opter",passwd=password,db=db)
    cursor = conn.cursor()

    items = list(config.items())
    names = ','.join([str(n) for (n,v) in items])
    values = ','.join(['%s' for (n,v) in items])
    names += ',id'
    values += ',"REQUESTED"'
    
    #do five variations
    for split in range(5):
        seed = np.random.randint(0,100000)
        n = names + ',split,seed'
        v = values + ',%d,%d' % (split,seed) 
        insert = 'INSERT INTO params (%s) VALUES (%s)' % (n,v)
        cursor.execute(insert,[v for (n,v) in items])
            
    conn.commit()
add rows from fname into database, starting at row start
add rows from fname into database, starting at row start
add rows from fname into database starting at row start
def addrows(config,host,db,password):
    conn = MySQLdb.connect (host = host,user = "opter",passwd=password,db=db)
    cursor = conn.cursor()
    items = list(config.items())
    names = ','.join([str(n) for (n,v) in items])
    values = ','.join(['%s' for (n,v) in items])
    names += ',id'
    values += ',"REQUESTED"'
    for split in range(5):
        seed = np.random.randint(0,100000)
        n = names + ',split,seed'
        v = values + ',%d,%d' % (split,seed) 
        insert = 'INSERT INTO params (%s) VALUES (%s)' % (n,v)
        cursor.execute(insert,[v for (n,v) in items])
    conn.commit()
def addrows ( config , host , db , password ) : conn = MySQLdb . connect ( host = host , user = "opter" , passwd = password , db = db ) cursor = conn . cursor ( ) items = list ( config . items ( ) ) names = ',' . join ( [ str ( n ) for ( n , v ) in items ] ) values = ',' . join ( [ '%s' for ( n , v ) in items ] ) names += ',id' values += ',"REQUESTED"' for split in range ( 5 ) : seed = np . random . randint ( 0 , 100000 ) n = names + ',split,seed' v = values + ',%d,%d' % ( split , seed ) insert = 'INSERT INTO params (%s) VALUES (%s)' % ( n , v ) cursor . execute ( insert , [ v for ( n , v ) in items ] ) conn . commit ( )
add rows from fname into database, starting at row start
add rows from fname into database starting at row start
'''add rows from fname into database, starting at row start''' #do five variations
config
host
db
password