Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from pymongo import Connection
- connection = Connection('localhost', 27017)
- def get_db_names():
- return connection.database_names()
- def get_collection_names(db_name):
- print '====================================='
- print 'DB: %s' % db_name
- __db = connection[db_name]
- return __db.collection_names()
- def main():
- for __db_name in get_db_names():
- __collecions = get_collection_names(__db_name)
- for __collection_name in __collecions:
- __collection_count = connection[__db_name][__collection_name].count()
- print 'TARGET COLLECTION: %s, COUNT: %s' % (__collection_name, __collection_count)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement