Created
May 29, 2017 23:11
-
-
Save WoodProgrammer/a156f93cbafd715d049ccb744a693f32 to your computer and use it in GitHub Desktop.
This file contains 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
from pymongo import * | |
import pprint | |
class Users: | |
def __init__(self): | |
self.client=MongoClient('localhost',27017) | |
self.db=self.client.telegram | |
def all(self,cn,arg1=None): | |
main_data = self.db["{}".format(cn)].find() | |
if arg1 is None: | |
return pprint.pprint(main_data) | |
else: | |
for i in main_data: | |
try: | |
pprint.pprint(i[arg1]) | |
except Exception as e: | |
pass | |
cli_test = Users() | |
cli_test.all('telegramcollection','name') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment