Created
June 14, 2017 21:57
-
-
Save tamr/5932b7f19ac9cf30e6f81968f13b10a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
from pymongo import * | |
import json,sys | |
def mongo_get(hosts): | |
client = MongoClient(hosts, 27017) | |
dbs = client.database_names() | |
for db in dbs: | |
mydb = client[db] | |
cols = mydb.collection_names() | |
for col in cols: | |
book = mydb[col] | |
print '---------------------------------------------------------------------' | |
print 'DB:'+db+'----'+'Collections:'+col | |
cont = str(book.find_one()) | |
print cont.decode('unicode_escape') | |
print 'Number:'+str(book.find().count()) | |
mongo_get(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment