countDtata.py 531 Bytes
Newer Older
Tianyang's avatar
Tianyang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
import cassandra.cluster
def countData(database,session):
    years = [i for i in range(2008,2018)]
    for year in years:
        count = 0
        number = session.execute_async("select year from caitiany.%s where year = %d ALLOW FILTERING" %(database,year))
        for row in number.result():
            count += 1
        print (year,' has ',count,' datas.\n')
if __name__ == "__main__":
    cluster = cassandra.cluster.Cluster(['localhost'])
    session = cluster.connect('caitiany')
    countData('database_espace',session)