# -*- coding:utf-8 -*-
import leveldb

dbname = 'artist_db1'
target_area = 'Japan'

def area_count(db, target_area):
    num = 0
    for name, area in db.RangeIter():
        if area == target_area:
            num += 1
    return num

def main(dbname, target_area):
    db = leveldb.LevelDB(dbname)
    num = area_count(db, target_area)
    print 'The number of artist in %s is %s' % (target_area, num)

if __name__ == '__main__':
    main(dbname, target_area)
