File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515#
16+ import contextlib
1617import json
1718import os
1819import re
@@ -230,15 +231,17 @@ def _parse_catalog_schema(db: str):
230231 sql_res .append (convert_decimals (df .to_dict (orient = "records" )))
231232 formalized_content .append (df .to_markdown (index = False , floatfmt = ".6f" ))
232233 finally :
233- ibm_db .close (conn )
234+ with contextlib .suppress (Exception ):
235+ ibm_db .close (conn )
234236
235237 self .set_output ("json" , sql_res )
236238 self .set_output ("formalized_content" , "\n \n " .join (formalized_content ))
237239 return self .output ("formalized_content" )
238240 try :
239241 cursor = db .cursor ()
240242 except Exception as e :
241- db .close ()
243+ with contextlib .suppress (Exception ):
244+ db .close ()
242245 raise Exception ("Database Connection Failed! \n " + str (e ))
243246
244247 try :
@@ -272,8 +275,10 @@ def _parse_catalog_schema(db: str):
272275 sql_res .append (convert_decimals (single_res .to_dict (orient = 'records' )))
273276 formalized_content .append (single_res .to_markdown (index = False , floatfmt = ".6f" ))
274277 finally :
275- cursor .close ()
276- db .close ()
278+ with contextlib .suppress (Exception ):
279+ cursor .close ()
280+ with contextlib .suppress (Exception ):
281+ db .close ()
277282
278283 self .set_output ("json" , sql_res )
279284 self .set_output ("formalized_content" , "\n \n " .join (formalized_content ))
You can’t perform that action at this time.
0 commit comments