from pymongo import MongoClient client = MongoClient() db = client.voyagerDB COL_WIDTH = 30 SMALL_COL_WIDTH = 13 totalStorageSize = 0 print("\nCOLLECTION".ljust(COL_WIDTH) + "\tSTORAGE_SIZE".ljust(SMALL_COL_WIDTH) + "\tCAPPED\n") for coll in db.collection_names(): stats = db.command("collstats", coll) totalStorageSize+=stats['storageSize'] if 'capped' in list(stats): cap = True else: cap = False print(coll.ljust(COL_WIDTH) + "\t" + str(stats['storageSize']).ljust(SMALL_COL_WIDTH) + "\t" + str(cap)) print("\nTOTAL STORAGE_SIZE : "+str(totalStorageSize))