Esempio n. 1
0
def insertData():
    db = DBCassandra(['127.0.0.1'],9042)
    db.connect('pdc03')
    with open('../donnees/temp.csv', 'r') as csvfile:
        reader = csv.reader(csvfile.read().splitlines())
        for row in reader:
            row_str = "".join(row)
            print row_str
            CQLString = "INSERT INTO documents (type, country, number) VALUES ('"+row[0]+"', '"+row[1]+"', '"+row[2]+"');"
            db.session.execute(CQLString)
    db.close()
Esempio n. 2
0
if __name__ == '__main__':
    # insertData()
    # init_bloom_filter()
    bloom = read_bloom_filter()
    print bloom.nb_hash
    print len(bloom.bitArray)
    # with open('../donnees/temp.csv', 'r') as csvfile:
    #     reader = csv.reader(csvfile.read().splitlines())
    #     for row in reader:
    #         row_str = "".join(row)
    #         print row_str
    #         bloom.exist(row_str)
    type_doc = "TES"
    country = "JPN"
    number = "K100000000JPN1111111"
    key = type_doc + country + number
    print key
    if bloom.exist(key):
        db = DBCassandra(['127.0.0.1'],9042)
        db.connect('pdc03')
        CQLString = "SELECT * FROM documents WHERE type = '"+type_doc+"' and country = '"+country+"' and number = '"+number+"';"
        print CQLString
        results = db.session.execute(CQLString)
        for result in results:
            print result.type+result.country+result.number
        db.close()
    else:
        print ("Doc n'existe pas")