Spaces:
Running
Running
ksvmuralidhar
commited on
Commit
•
bf81ef0
1
Parent(s):
5d46f28
Update db_operations/db_operations.py
Browse files
db_operations/db_operations.py
CHANGED
@@ -22,6 +22,7 @@ class DBOperations:
|
|
22 |
_ = self.__client.list_database_names()
|
23 |
except Exception as conn_exception:
|
24 |
self.__error = 1
|
|
|
25 |
self.__client = None
|
26 |
raise
|
27 |
|
@@ -35,12 +36,14 @@ class DBOperations:
|
|
35 |
if (len(docs) == 0) and (ntry < maxtries):
|
36 |
for doc in coll.find():
|
37 |
docs.append(doc)
|
38 |
-
|
|
|
39 |
time.sleep(5)
|
40 |
|
41 |
rss_df = pd.DataFrame(docs)
|
42 |
except Exception as insert_err:
|
43 |
self.__error = 1
|
|
|
44 |
rss_df = pd.DataFrame({'_id': '', 'title': '', 'url': '',
|
45 |
'description': '', 'parsed_date': '',
|
46 |
'src': ''}, index=[0])
|
@@ -61,7 +64,7 @@ class DBOperations:
|
|
61 |
if self.__error == 0:
|
62 |
rss_df = await self.__read()
|
63 |
if self.__error == 0:
|
64 |
-
|
65 |
if self.__client is not None:
|
66 |
self.__close_connection()
|
67 |
return rss_df
|
|
|
22 |
_ = self.__client.list_database_names()
|
23 |
except Exception as conn_exception:
|
24 |
self.__error = 1
|
25 |
+
logging.critical(f"Error in DBOperations.connect(): {conn_exception}")
|
26 |
self.__client = None
|
27 |
raise
|
28 |
|
|
|
36 |
if (len(docs) == 0) and (ntry < maxtries):
|
37 |
for doc in coll.find():
|
38 |
docs.append(doc)
|
39 |
+
logging.info(f"DB Read try: {ntry}")
|
40 |
+
conn_exception
|
41 |
time.sleep(5)
|
42 |
|
43 |
rss_df = pd.DataFrame(docs)
|
44 |
except Exception as insert_err:
|
45 |
self.__error = 1
|
46 |
+
logging.critical(f"Error in DBOperations.read(): {insert_err}")
|
47 |
rss_df = pd.DataFrame({'_id': '', 'title': '', 'url': '',
|
48 |
'description': '', 'parsed_date': '',
|
49 |
'src': ''}, index=[0])
|
|
|
64 |
if self.__error == 0:
|
65 |
rss_df = await self.__read()
|
66 |
if self.__error == 0:
|
67 |
+
logging.info("Read Successful")
|
68 |
if self.__client is not None:
|
69 |
self.__close_connection()
|
70 |
return rss_df
|