-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit_dal.py
More file actions
34 lines (25 loc) · 787 Bytes
/
commit_dal.py
File metadata and controls
34 lines (25 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 29 13:29:07 2018
@author: natha
"""
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 18 14:16:20 2018
@author: natha
"""
from pymongo import MongoClient
class CommitDal:
def __init__(self):
self.client = MongoClient()
self.db = self.client["graduation"]
self.collection = self.db["commits"]
def count_commits(self):
return self.collection.estimated_document_count()
def insert_commits(self, commits):
try:
for commit in commits:
self.collection.insert(commit)
except Exception as e:
print("Failed inserting commit {} with url {}, error: {}".format(commit["commit_sha"], commit["html_url"], e))
raise e