utils.py 800 B

123456789101112131415161718192021222324252627282930
  1. # from pymongo import MongoClient
  2. class Utils:
  3. def __init__(self, col="test"):
  4. self.GET = 1
  5. self.UPD = 2
  6. self.CLS = 3
  7. self.EXC = 4
  8. # self.cli = MongoClient("mongodb://chassis:chassis@127.0.0.1:27017/")
  9. # self.db = self.cli["chassis"]
  10. # self.col = col
  11. # async def insert(self, parm):
  12. # self.db[self.col].insert_many(parm)
  13. # await self.cli.close()
  14. # async def find(self, cond):
  15. # ret = self.db[self.col].find({}, cond)
  16. # await self.cli.close()
  17. # return ret
  18. # async def delete(self, cond):
  19. # self.db[self.col].delete_many(cond)
  20. # await self.cli.close()
  21. # async def update(self, cond):
  22. # self.db[self.col].update_many(cond)
  23. # await self.cli.close()