Skip to content

Commit

Permalink
Revert "#123 Added Ibis connection (#124)"
Browse files Browse the repository at this point in the history
This reverts commit 3a7f889.
  • Loading branch information
tomuben committed Jul 18, 2024
1 parent 190ad2c commit e0957f9
Show file tree
Hide file tree
Showing 7 changed files with 566 additions and 797 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: SCM Checkout
Expand All @@ -70,7 +70,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: SCM Checkout
Expand All @@ -91,7 +91,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
exasol-version: ["7.1.9"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* #110 Added the support of SaaS to the extension wrappers.
- Added SaaS configuration parameters in a call to the language container deployer.
- Changed how the bucketfs parameters are stored in a connection object.
* #123 Added a function that opens a connection to Ibis.

81 changes: 24 additions & 57 deletions exasol/nb_connector/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pyexasol # type: ignore
import sqlalchemy # type: ignore
from sqlalchemy.engine.url import URL # type: ignore
import ibis # type: ignore

import exasol.bucketfs as bfs # type: ignore
import exasol.saas.client.api_access as saas_api # type: ignore
Expand Down Expand Up @@ -102,34 +101,6 @@ def get_saas_database_id(conf: Secrets) -> str:
database_name=conf.get(CKey.saas_database_name))


def _get_pyexasol_connection_params(conf: Secrets, **kwargs) -> dict[str, Any]:

if get_backend(conf) == StorageBackend.onprem:
conn_params: dict[str, Any] = {
"dsn": get_external_host(conf),
"user": conf.get(CKey.db_user),
"password": conf.get(CKey.db_password),
}
else:
conn_params = saas_api.get_connection_params(
host=conf.get(CKey.saas_url),
account_id=conf.get(CKey.saas_account_id),
pat=conf.get(CKey.saas_token),
database_id=conf.get(CKey.saas_database_id),
database_name=conf.get(CKey.saas_database_name)
)

encryption = _optional_encryption(conf)
if encryption is not None:
conn_params["encryption"] = encryption
ssopt = _extract_ssl_options(conf)
if ssopt:
conn_params["websocket_sslopt"] = ssopt

conn_params.update(kwargs)
return conn_params


def open_pyexasol_connection(conf: Secrets, **kwargs) -> pyexasol.ExaConnection:
"""
Opens a pyexasol connection using provided configuration parameters.
Expand All @@ -156,7 +127,30 @@ def open_pyexasol_connection(conf: Secrets, **kwargs) -> pyexasol.ExaConnection:
For other optional parameters the default settings are as per the pyexasol interface.
"""

conn_params = _get_pyexasol_connection_params(conf, **kwargs)
if get_backend(conf) == StorageBackend.onprem:
conn_params: dict[str, Any] = {
"dsn": get_external_host(conf),
"user": conf.get(CKey.db_user),
"password": conf.get(CKey.db_password),
}
else:
conn_params = saas_api.get_connection_params(
host=conf.get(CKey.saas_url),
account_id=conf.get(CKey.saas_account_id),
pat=conf.get(CKey.saas_token),
database_id=conf.get(CKey.saas_database_id),
database_name=conf.get(CKey.saas_database_name)
)

encryption = _optional_encryption(conf)
if encryption is not None:
conn_params["encryption"] = encryption
ssopt = _extract_ssl_options(conf)
if ssopt:
conn_params["websocket_sslopt"] = ssopt

conn_params.update(kwargs)

return pyexasol.connect(**conn_params)


Expand Down Expand Up @@ -276,30 +270,3 @@ def open_bucketfs_connection(conf: Secrets) -> bfs.BucketLike:
account_id=saas_account_id,
database_id=saas_database_id,
pat=saas_token)


def open_ibis_connection(conf: Secrets, **kwargs):
"""
Creates a connection to Ibis with Exasol backend.
The parameters are similar to those of open_pyexasol_connection function.
The downstream call signature is also similar to pyexasol, except that the dsn is
provided in two separate parts - host and port.
Unlike open_pyexasol_connection, this function sets the default schema if it's
defined in the configuration.
"""

conn_params = _get_pyexasol_connection_params(conf, **kwargs)

dsn = conn_params.pop('dsn')
host_port = dsn.split(':')
conn_params['host'] = host_port[0]
if len(host_port) > 1:
conn_params['port'] = int(host_port[1])

schema = conf.get(CKey.db_schema)
if schema:
conn_params['schema'] = schema

return ibis.exasol.connect(**conn_params)
Loading

0 comments on commit e0957f9

Please sign in to comment.