Spaces:
Runtime error
Runtime error
ksvmuralidhar
commited on
Commit
•
25297ae
1
Parent(s):
87a5037
Update db_operations/db_operations.py
Browse files
db_operations/db_operations.py
CHANGED
@@ -14,7 +14,7 @@ class DBOperations:
|
|
14 |
self.__client = None
|
15 |
self.__error = 0
|
16 |
|
17 |
-
def __connect(self):
|
18 |
try:
|
19 |
self.__client = pymongo.MongoClient(self.url)
|
20 |
_ = self.__client.list_database_names()
|
@@ -23,7 +23,7 @@ class DBOperations:
|
|
23 |
self.__client = None
|
24 |
raise
|
25 |
|
26 |
-
def __read(self):
|
27 |
try:
|
28 |
db = self.__client[self.database]
|
29 |
coll = db[self.collection]
|
@@ -43,15 +43,15 @@ class DBOperations:
|
|
43 |
self.__client.close()
|
44 |
self.__client = None
|
45 |
|
46 |
-
def read_news_from_db(self):
|
47 |
rss_df = pd.DataFrame({'_id': '', 'title': '', 'url': '',
|
48 |
'description': '', 'parsed_date': '',
|
49 |
'src': ''}, index=[0])
|
50 |
if self.url is not None:
|
51 |
if self.__error == 0:
|
52 |
-
self.__connect()
|
53 |
if self.__error == 0:
|
54 |
-
rss_df = self.__read()
|
55 |
if self.__error == 0:
|
56 |
print("Read Successful")
|
57 |
if self.__client is not None:
|
|
|
14 |
self.__client = None
|
15 |
self.__error = 0
|
16 |
|
17 |
+
async def __connect(self):
|
18 |
try:
|
19 |
self.__client = pymongo.MongoClient(self.url)
|
20 |
_ = self.__client.list_database_names()
|
|
|
23 |
self.__client = None
|
24 |
raise
|
25 |
|
26 |
+
async def __read(self):
|
27 |
try:
|
28 |
db = self.__client[self.database]
|
29 |
coll = db[self.collection]
|
|
|
43 |
self.__client.close()
|
44 |
self.__client = None
|
45 |
|
46 |
+
async def read_news_from_db(self):
|
47 |
rss_df = pd.DataFrame({'_id': '', 'title': '', 'url': '',
|
48 |
'description': '', 'parsed_date': '',
|
49 |
'src': ''}, index=[0])
|
50 |
if self.url is not None:
|
51 |
if self.__error == 0:
|
52 |
+
await self.__connect()
|
53 |
if self.__error == 0:
|
54 |
+
rss_df = await self.__read()
|
55 |
if self.__error == 0:
|
56 |
print("Read Successful")
|
57 |
if self.__client is not None:
|