Skip to content

Commit

Permalink
✨ Added close_connection() to sap_rfc (dyvenia#709)
Browse files Browse the repository at this point in the history
* ✨ Added `close_connection()`

* 📝 Added `close_connection()` in `sap_rfc`

* Update CHANGELOG.md

Co-authored-by: Michał Zawadzki <michalmzawadzki@gmail.com>

---------

Co-authored-by: Michał Zawadzki <michalmzawadzki@gmail.com>
  • Loading branch information
AnnaGerlich and trymzet authored Jun 21, 2023
1 parent b565ee4 commit 8b902c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `howto_migrate_sources_tasks_and_flows.md` document. This document will assist the DEs with the viadot 1 -> viadot 2 migration process.
- `RedshiftSpectrum.from_df()` now automatically creates a folder for the table if not specified in `to_path`
- Fixed a bug in `Databricks.create_table_from_pandas()`. The function now automatically casts DataFrame types. (#681)
- Added `close_connection()` to `SAPRFC`


### Changed
Expand Down
10 changes: 8 additions & 2 deletions viadot/sources/sap_rfc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import logging
import re
from collections import OrderedDict
from typing import List, Literal, Dict, Any
from typing import Any, Dict, List, Literal
from typing import OrderedDict as OrderedDictType
from typing import Tuple, Union

Expand Down Expand Up @@ -153,6 +153,11 @@ def check_connection(self) -> None:
self.con.ping()
self.logger.info("Connection has been validated successfully.")

def close_connection(self) -> None:
"""Closing RFC connection."""
self.con.close()
self.logger.info("Connection has been closed successfully.")

def get_function_parameters(
self,
function_name: str,
Expand Down Expand Up @@ -511,5 +516,6 @@ def to_df(self):
if col not in self.select_columns_aliased
]
df.drop(cols_to_drop, axis=1, inplace=True)
self.close_connection()

return df

0 comments on commit 8b902c4

Please sign in to comment.