Advertisement
Guest User

Untitled

a guest
May 4th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from pymongo import Connection
  3. connection = Connection('localhost', 27017)
  4.  
  5.  
  6. def get_db_names():
  7. return connection.database_names()
  8.  
  9.  
  10. def get_collection_names(db_name):
  11. print '====================================='
  12. print 'DB: %s' % db_name
  13. __db = connection[db_name]
  14. return __db.collection_names()
  15.  
  16.  
  17. def main():
  18. for __db_name in get_db_names():
  19. __collecions = get_collection_names(__db_name)
  20. for __collection_name in __collecions:
  21. __collection_count = connection[__db_name][__collection_name].count()
  22. print 'TARGET COLLECTION: %s, COUNT: %s' % (__collection_name, __collection_count)
  23.  
  24. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement