Skip to content

Commit

Permalink
Updates the connections module (#33)
Browse files Browse the repository at this point in the history
* Updates the connections module

* Making mypy happy
  • Loading branch information
ahsimb authored Nov 28, 2023
1 parent caeff51 commit bedd0e2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions doc/changes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes

* [0.2.3](changes_0.2.3.md)
* [0.2.2](changes_0.2.2.md)
* [0.2.1](changes_0.2.1.md)
* [0.2.0](changes_0.2.0.md)
Expand All @@ -11,6 +12,7 @@
---
hidden:
---
changes_0.2.3
changes_0.2.2
changes_0.2.1
changes_0.2.0
Expand Down
10 changes: 10 additions & 0 deletions doc/changes/changes_0.2.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Exasol Notebook Connector 0.2.3, released 2023-11-28

## Summary

This release makes another small update to the connections module

## Changes

* #31: Add a function returning an udf bucket path.
* #32: Temporarily disables https connection to BucketFs.
21 changes: 17 additions & 4 deletions exasol/connections.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import ssl
from pathlib import Path
from typing import Optional
from typing import Optional, Any

import pyexasol # type: ignore
import sqlalchemy # type: ignore

import exasol.bucketfs as bfs # type: ignore
from exasol.secret_store import Secrets

Expand Down Expand Up @@ -65,11 +66,19 @@ def _extract_ssl_options(conf: Secrets) -> dict:
return sslopt


def get_external_host(conf: Secrets):
def get_external_host(conf: Secrets) -> str:
"""Constructs the host part of a DB URL using provided configuration parameters."""
return f"{conf.EXTERNAL_HOST_NAME}:{conf.DB_PORT}"


def get_udf_bucket_path(conf: Secrets) -> str:
"""
Builds the path of the BucketFS bucket specified in the configuration,
as it's seen in the udf's file system.
"""
return f"/buckets/{conf.BUCKETFS_SERVICE}/{conf.BUCKETFS_BUCKET}"


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

conn_params = {
conn_params: dict[str, Any] = {
"dsn": get_external_host(conf),
"user": conf.USER,
"password": conf.PASSWORD,
Expand Down Expand Up @@ -158,7 +167,11 @@ def open_bucketfs_connection(conf: Secrets) -> bfs.Bucket:
"""

# Set up the connection parameters.
buckfs_url_prefix = "https" if _optional_encryption(conf) else "http"
# For now, just use the http. Once the exasol.bucketfs is capable of using the
# https without validating the server certificate choose between the http and
# https depending on the ENCRYPTION setting like in the code below:
# buckfs_url_prefix = "https" if _optional_encryption(conf) else "http"
buckfs_url_prefix = "http"
buckfs_url = f"{buckfs_url_prefix}://{conf.EXTERNAL_HOST_NAME}:{conf.BUCKETFS_PORT}"
buckfs_credentials = {
conf.BUCKETFS_BUCKET: {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "exasol-notebook-connector"
version = "0.2.2"
version = "0.2.3"
description = "Components, tools, APIs, and configurations in order to connect Jupyter notebooks to Exasol and various other systems."
packages = [ {include = "exasol"}, ]
authors = [ "Christoph Kuhnke <[email protected]>" ]
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
MAJOR = 0
MINOR = 2
PATCH = 2
PATCH = 3
VERSION = f"{MAJOR}.{MINOR}.{PATCH}"

0 comments on commit bedd0e2

Please sign in to comment.