Example #1
0
    def __init__(self):
        self.mongo_uri = MONGODB_SERVER
        self.mongo_db = MONGODB_DB
        self.mongo_port = MONGODB_PORT
        self.client = client(self.mongo_uri, self.mongo_port)

        self.db = self.client[self.mongo_db]
        self.collection = self.db[self.collection_name]
Example #2
0
import os
try:
  import pymongo, motor
except:
  os.system("pip install pymongo && pip install motor")
from pymongo import MongoClient as client
def ch(var):
  k = os.environ.get(var)
  return k
mg = ch("MONGO_URI")
database = client(mg)
mongo = database ["XGAME"]
# MONGO DONE
try:
  import telethon
except:
  os.system("pip install telethon")
token = ch("TOKEN")
api = ch("API_ID")
hash = ch("API_HASH")
from telethon import TelegramClient as tg
bot = tg(api, hash).start(bot_token=token)
Example #3
0
                });
            }
            """)

reducer = code("""
            function(key, values) {
                var total = 0;
                for (var i = 0; i < values.length; i++) {
                    total += values[i];
                }
                return total;
            }
            """)


db = client().demo
result = db.animals.map_reduce(mapper, reducer, "myresults")

for doc in result.find():
    print doc


# get more detailed results when desired, by passing full_response=True to map_reduce()
result = db.animals.map_reduce(mapper, reducer, "myresults", full_response=True)

# all of the optional map/reduce parameters are also supported, simply pass them as keyword arguments
result = db.animals.map_reduce(mapper, reducer, "myresults", query={"x": {"$gt": 2}})

# can use SON or collections.OrderedDict to specify a different database to store the result collection
result = db.animals.map_reduce(mapper, reducer, out=son([("replace", "results"), ("db", "outdb")]), full_response=True)
Example #4
0
def connectdb():
    from pymongo import MongoClient as client
    connect = client('mongodb://localhost:27017/')
    db = connect.osint
    return db