Advertisement
Guest User

Untitled

a guest
May 26th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. """
  2. Created on Tue Sep 18 14:16:20 2018
  3.  
  4. @author: natha
  5. """
  6.  
  7. from pymongo import MongoClient
  8.  
  9. class CommitDal:
  10. def __init__(self):
  11. self.client = MongoClient()
  12. self.db = self.client["graduation"]
  13. self.collection = self.db["commits"]
  14.  
  15. def count_commits(self):
  16. return self.collection.estimated_document_count()
  17.  
  18.  
  19. def insert_commits(self, commits):
  20. try:
  21. for commit in commits:
  22. self.collection.insert(commit)
  23. except Exception as e:
  24. print("Failed inserting commit {} with url {}, error: {}".format(commit["commit_sha"], commit["html_url"], e))
  25. raise e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement