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

Support the hdbcli client library #10595

Merged
merged 4 commits into from
Nov 12, 2021
Merged

Support the hdbcli client library #10595

merged 4 commits into from
Nov 12, 2021

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Nov 10, 2021

Motivation

https://github.com/SAP-archive/PyHDB

This public repository is read-only and no longer maintained.
The active maintained alternative is SAP HANA Python Client: https://pypi.org/project/hdbcli/

@codecov
Copy link

codecov bot commented Nov 10, 2021

Codecov Report

Merging #10595 (c18ce29) into master (adb1aa2) will decrease coverage by 0.00%.
The diff coverage is 83.92%.

Flag Coverage Δ
sap_hana 92.12% <83.92%> (-0.90%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@sarah-witt sarah-witt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I left a few comments

sap_hana/assets/configuration/spec.yaml Show resolved Hide resolved
sap_hana/assets/configuration/spec.yaml Show resolved Hide resolved
sap_hana/tests/test_unit.py Show resolved Hide resolved
https://help.sap.com/viewer/f1b440ded6144a54ada97ff95dac7adf/2.10/en-US/ee592e89dcce4480a99571a4ae7a702f.html
value:
type: object
additionalProperties: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sap_hana/README.md Outdated Show resolved Hide resolved
Comment on lines +587 to +651
if USING_HDBCLI:

def get_connection(self):
# https://help.sap.com/viewer/f1b440ded6144a54ada97ff95dac7adf/2.10/en-US/ee592e89dcce4480a99571a4ae7a702f.html
connection_properties = self.instance.get('connection_properties', {}).copy()

connection_properties.setdefault('address', self._server)
connection_properties.setdefault('port', self._port)
connection_properties.setdefault('user', self._username)
connection_properties.setdefault('password', self._password)

timeout_milliseconds = int(self._timeout * 1000)
connection_properties.setdefault('communicationTimeout', timeout_milliseconds)
connection_properties.setdefault('nodeConnectTimeout', timeout_milliseconds)

if self._use_tls:
connection_properties.setdefault('encrypt', True)
connection_properties.setdefault('sslHostNameInCertificate', self._server)
connection_properties.setdefault('sslSNIHostname', self._server)

tls_verify = self.instance.get('tls_verify', True)
if not tls_verify:
connection_properties.setdefault('sslValidateCertificate', False)

tls_cert = self.instance.get('tls_cert')
if tls_cert:
connection_properties.setdefault('sslKeyStore', tls_cert)

tls_ca_cert = self.instance.get('tls_ca_cert')
if tls_ca_cert:
connection_properties.setdefault('sslTrustStore', tls_ca_cert)
elif not connection_properties.get('sslUseDefaultTrustStore', True):
connection_properties.setdefault('sslTrustStore', certifi.where())

try:
connection = HanaConnection(**connection_properties)
except Exception as e:
error = str(e)
self.log.error('Unable to connect to SAP HANA: %s', error)
self.service_check(self.SERVICE_CHECK_CONNECT, self.CRITICAL, message=error, tags=self._tags)
else:
self.service_check(self.SERVICE_CHECK_CONNECT, self.OK, tags=self._tags)
return connection

else:

def get_connection(self):
try:
tls_context = self.get_tls_context() if self._use_tls else None
connection = HanaConnection(
host=self._server,
port=self._port,
user=self._username,
password=self._password,
tls_context=tls_context,
timeout=self._timeout,
)
connection.connect()
except Exception as e:
error = str(e)
self.log.error('Unable to connect to SAP HANA: %s', error)
self.service_check(self.SERVICE_CHECK_CONNECT, self.CRITICAL, message=error, tags=self._tags)
else:
self.service_check(self.SERVICE_CHECK_CONNECT, self.OK, tags=self._tags)
return connection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in connection.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No b/c I think it makes more sense for the split in config logic to be closer to the check since it needs attributes of the check

sarah-witt
sarah-witt previously approved these changes Nov 10, 2021
Copy link
Contributor

@ruthnaebeck ruthnaebeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs review

sap_hana/README.md Outdated Show resolved Hide resolved
Co-authored-by: ruthnaebeck <19349244+ruthnaebeck@users.noreply.github.com>
Copy link
Contributor

@ruthnaebeck ruthnaebeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for docs

@ofek ofek merged commit f2c7e3a into master Nov 12, 2021
@ofek ofek deleted the ofek/sap-hana branch November 12, 2021 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants