SHARE
TWEET

Untitled

a guest May 26th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top