Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hana) rollback upgrade #439

Merged
merged 2 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'oracle_sql': ['cx_Oracle>=6.2.1'],
'postgres': ['psycopg2>=2.7.4'],
'ROK': ['requests', 'pyjwt', 'simplejson'],
'sap_hana': ['hdbcli'],
'sap_hana': ['pyhdb>=0.3.4'],
'soap': ['zeep', 'lxml==4.2.5'],
'snowflake': ['snowflake-connector-python==2.4.1'],
'toucan_toco': ['toucan_client'],
Expand Down
4 changes: 2 additions & 2 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mongo:
- 27017:27017

mssql:
image: microsoft/mssql-server-linux
image: mcr.microsoft.com/mssql/server:2019-latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Il0veT0uc@n!
Expand Down Expand Up @@ -70,4 +70,4 @@ clickhouse:
CLICKHOUSE_PASSWORD: ilovetoucan
newtork: host
volumes:
- ./clickhouse/fixtures/toucan_entrypoint.sh:/docker-entrypoint-initdb.d/toucan_entrypoint.sh
- ./clickhouse/fixtures/toucan_entrypoint.sh:/docker-entrypoint-initdb.d/toucan_entrypoint.sh
8 changes: 4 additions & 4 deletions tests/sap_hana/test_sap_hana.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_raise_on_empty_query():


def test_saphana_get_df(mocker):
snock = mocker.patch('hdbcli.dbapi.connect')
snock = mocker.patch('pyhdb.connect')
reasq = mocker.patch('pandas.read_sql')

saphana_connector = SapHanaConnector(
Expand All @@ -25,17 +25,17 @@ def test_saphana_get_df(mocker):
ds = SapHanaDataSource(domain='test', name='test', query='my_query')
saphana_connector.get_df(ds)

snock.assert_called_once_with(address='localhost', port=22, user='ubuntu', password='truc')
snock.assert_called_once_with('localhost', 22, 'ubuntu', 'truc')
reasq.assert_called_once_with('my_query', con=snock(), params=None)


def test_saphana_get_df_no_pw(mocker):
snock = mocker.patch('hdbcli.dbapi.connect')
snock = mocker.patch('pyhdb.connect')
reasq = mocker.patch('pandas.read_sql')

saphana_connector = SapHanaConnector(name='test', host='localhost', port=22, user='ubuntu')
ds = SapHanaDataSource(domain='test', name='test', query='my_query')
saphana_connector.get_df(ds)

snock.assert_called_once_with(address='localhost', port=22, user='ubuntu', password='')
snock.assert_called_once_with('localhost', 22, 'ubuntu', '')
reasq.assert_called_once_with('my_query', con=snock(), params=None)
12 changes: 6 additions & 6 deletions toucan_connectors/sap_hana/sap_hana_connector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hdbcli import dbapi
import pyhdb
from pydantic import Field, SecretStr, constr

from toucan_connectors.common import pandas_read_sql
Expand Down Expand Up @@ -29,11 +29,11 @@ class SapHanaConnector(ToucanConnector):
password: SecretStr = Field('', description='Your login password')

def _retrieve_data(self, data_source):
connection = dbapi.connect(
address=self.host,
port=self.port,
user=self.user,
password=self.password.get_secret_value() if self.password else '',
connection = pyhdb.connect(
self.host,
self.port,
self.user,
self.password.get_secret_value() if self.password else SecretStr('').get_secret_value(),
)

df = pandas_read_sql(data_source.query, con=connection)
Expand Down