ksvmuralidhar commited on
Commit
78820fa
1 Parent(s): a2ea6d9

Update db_operations/db_operations.py

Browse files
Files changed (1) hide show
  1. db_operations/db_operations.py +6 -5
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,17 +43,18 @@ 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:
58
  self.__close_connection()
59
  return rss_df
 
 
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:
58
  self.__close_connection()
59
  return rss_df
60
+