Spaces:
Running
Running
Commit
•
5d46f28
1
Parent(s):
bf77e6e
Update db_operations/db_operations.py
Browse files
db_operations/db_operations.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import pymongo
|
2 |
import os
|
3 |
import pandas as pd
|
|
|
|
|
4 |
|
5 |
|
6 |
class DBOperations:
|
@@ -28,8 +30,14 @@ class DBOperations:
|
|
28 |
db = self.__client[self.database]
|
29 |
coll = db[self.collection]
|
30 |
docs = []
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
rss_df = pd.DataFrame(docs)
|
34 |
except Exception as insert_err:
|
35 |
self.__error = 1
|
|
|
1 |
import pymongo
|
2 |
import os
|
3 |
import pandas as pd
|
4 |
+
import time
|
5 |
+
import logging
|
6 |
|
7 |
|
8 |
class DBOperations:
|
|
|
30 |
db = self.__client[self.database]
|
31 |
coll = db[self.collection]
|
32 |
docs = []
|
33 |
+
maxtries = 3
|
34 |
+
ntry = 0
|
35 |
+
if (len(docs) == 0) and (ntry < maxtries):
|
36 |
+
for doc in coll.find():
|
37 |
+
docs.append(doc)
|
38 |
+
ntry += 1
|
39 |
+
time.sleep(5)
|
40 |
+
|
41 |
rss_df = pd.DataFrame(docs)
|
42 |
except Exception as insert_err:
|
43 |
self.__error = 1
|