def _insert_data(con, data):
    """
    insert line for each cluster
    """
    with con:
        cur = con.cursor()
        cur.execute("DROP TABLE IF EXISTS clusters;")
        cur.execute("CREATE TABLE clusters(Id INT, Description TEXT, Locus TEXT, Annotation TEXT, Sequences TEXT, Profile TXT, Precursor TXT)")
        for c in data[0]:
            locus = json.dumps(data[0][c]['loci'])
            annotation = json.dumps(data[0][c]['ann'])
            description = _get_description(data[0][c]['ann'])
            sequences = json.dumps(_get_sequences(data[0][c]))
            keys = data[0][c]['freq'][0].values()[0].keys()
            profile = "Not available."
            if 'profile' in data[0][c]:
                profile = json.dumps(_set_format(data[0][c]['profile']))
            precursor = json.dumps(data[0][c].get('precursor'))
            cur.execute("INSERT INTO clusters VALUES(%s, '%s', '%s', '%s', '%s', '%s', '%s')" % (c, description, locus, annotation, sequences, profile, precursor))
def _insert_data ( con , data ) : with con : cur = con . cursor ( ) cur . execute ( "DROP TABLE IF EXISTS clusters;" ) cur . execute ( "CREATE TABLE clusters(Id INT, Description TEXT, Locus TEXT, Annotation TEXT, Sequences TEXT, Profile TXT, Precursor TXT)" ) for c in data [ 0 ] : locus = json . dumps ( data [ 0 ] [ c ] [ 'loci' ] ) annotation = json . dumps ( data [ 0 ] [ c ] [ 'ann' ] ) description = _get_description ( data [ 0 ] [ c ] [ 'ann' ] ) sequences = json . dumps ( _get_sequences ( data [ 0 ] [ c ] ) ) keys = data [ 0 ] [ c ] [ 'freq' ] [ 0 ] . values ( ) [ 0 ] . keys ( ) profile = "Not available." if 'profile' in data [ 0 ] [ c ] : profile = json . dumps ( _set_format ( data [ 0 ] [ c ] [ 'profile' ] ) ) precursor = json . dumps ( data [ 0 ] [ c ] . get ( 'precursor' ) ) cur . execute ( "INSERT INTO clusters VALUES(%s, '%s', '%s', '%s', '%s', '%s', '%s')" % ( c , description , locus , annotation , sequences , profile , precursor ) )
insert line for each cluster