diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e406f2d8..80f0d476e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +### Changed + +- MSSQL and Azure MSQQL connectors now use the ODBC 18 driver +- The Oracle connector install script is now compatible with Ubuntu 24.04 + ## [7.4.1] 2024-12-12 ### Fixed diff --git a/tests/mssql/test_mssql.py b/tests/mssql/test_mssql.py index 7b4f5754f..9a5a73842 100644 --- a/tests/mssql/test_mssql.py +++ b/tests/mssql/test_mssql.py @@ -16,7 +16,7 @@ def check_and_feed(host_port): but also feeds the database once it's up ! """ conn = pyodbc.connect( - driver="{ODBC Driver 17 for SQL Server}", + driver="{ODBC Driver 18 for SQL Server}", server=f"127.0.0.1,{host_port}", user="SA", password="Il0veT0uc@n!", @@ -63,7 +63,7 @@ def test_datasource(): def test_connection_params(): connector = MSSQLConnector(name="my_mssql_con", host="myhost", user="myuser") assert connector.get_connection_params(None) == { - "driver": "{ODBC Driver 17 for SQL Server}", + "driver": "{ODBC Driver 18 for SQL Server}", "server": "myhost", "user": "myuser", "as_dict": True, @@ -77,7 +77,7 @@ def test_connection_params(): connect_timeout=60, ) assert connector.get_connection_params("mydb") == { - "driver": "{ODBC Driver 17 for SQL Server}", + "driver": "{ODBC Driver 18 for SQL Server}", "server": "myhost,123", "user": "myuser", "as_dict": True, @@ -101,7 +101,7 @@ def test_mssql_get_df(mocker): mssql_connector.get_df(datasource) snock.assert_called_once_with( - driver="{ODBC Driver 17 for SQL Server}", + driver="{ODBC Driver 18 for SQL Server}", as_dict=True, server="127.0.0.1,22", user="SA", diff --git a/tests/mssql_TLSv1_0/test_mssql_TLSv1_0.py b/tests/mssql_TLSv1_0/test_mssql_TLSv1_0.py index 9ed3d0ad1..2c8f74853 100644 --- a/tests/mssql_TLSv1_0/test_mssql_TLSv1_0.py +++ b/tests/mssql_TLSv1_0/test_mssql_TLSv1_0.py @@ -16,7 +16,7 @@ def check_and_feed(host_port): but also feeds the database once it's up ! """ conn = pyodbc.connect( - driver="{ODBC Driver 17 for SQL Server}", + driver="{ODBC Driver 18 for SQL Server}", server=f"127.0.0.1,{host_port}", user="SA", password="Il0veT0uc@n!", @@ -64,7 +64,7 @@ def test_datasource(): def test_connection_params(): connector = MSSQLConnector(name="my_mssql_con", host="myhost", user="myuser") assert connector.get_connection_params(None) == { - "driver": "{ODBC Driver 17 for SQL Server}", + "driver": "{ODBC Driver 18 for SQL Server}", "server": "myhost", "user": "myuser", "as_dict": True, @@ -78,7 +78,7 @@ def test_connection_params(): connect_timeout=60, ) assert connector.get_connection_params("mydb") == { - "driver": "{ODBC Driver 17 for SQL Server}", + "driver": "{ODBC Driver 18 for SQL Server}", "server": "myhost,123", "user": "myuser", "as_dict": True, @@ -103,7 +103,7 @@ def test_mssql_get_df(mocker): mssql_connector.get_df(datasource) snock.assert_called_once_with( - driver="{ODBC Driver 17 for SQL Server}", + driver="{ODBC Driver 18 for SQL Server}", as_dict=True, server="127.0.0.1,22", user="SA", diff --git a/toucan_connectors/azure_mssql/azure_mssql_connector.py b/toucan_connectors/azure_mssql/azure_mssql_connector.py index 3a51846e4..968cc5691 100644 --- a/toucan_connectors/azure_mssql/azure_mssql_connector.py +++ b/toucan_connectors/azure_mssql/azure_mssql_connector.py @@ -63,7 +63,7 @@ def _create_engine(self, database: str | None) -> "sa.Engine": password = self.password.get_secret_value() if self.password else None query_params: dict[str, str] = { - "driver": "ODBC Driver 17 for SQL Server", + "driver": "ODBC Driver 18 for SQL Server", } if self.connect_timeout: query_params["timeout"] = str(self.connect_timeout) diff --git a/toucan_connectors/install_scripts/mssql.sh b/toucan_connectors/install_scripts/mssql.sh index 5add2fb78..b3794f11c 100755 --- a/toucan_connectors/install_scripts/mssql.sh +++ b/toucan_connectors/install_scripts/mssql.sh @@ -1,25 +1,26 @@ #!/bin/bash + set -e +# Supports debian 12 and ubuntu 24.04 + if [[ -e ~/mssql-installed ]]; then echo "MSSQL connector dependencies are already installed." exit fi apt-get update -apt-get install -fyq gnupg curl -curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - +apt-get install -fyq --no-install-recommends gnupg curl ca-certificates +curl -fsSL https://packages.microsoft.com/keys/microsoft.asc -o /tmp/microsoft-key.asc +# --batch to disable TTY and --yes to overwrite the file if it exists +gpg --batch --yes --dearmor -o /usr/share/keyrings/microsoft-prod.gpg /tmp/microsoft-key.asc +rm -f /tmp/microsoft-key.asc source /etc/os-release -if [ "$ID" == "debian" ]; then - # debian/12 fails - fixing to debian/11 works: - curl "https://packages.microsoft.com/config/debian/11/prod.list" \ - | tee /etc/apt/sources.list.d/mssql-release.list -else - curl "https://packages.microsoft.com/config/${ID}/${VERSION_ID}/prod.list" \ - | tee /etc/apt/sources.list.d/mssql-release.list -fi +curl "https://packages.microsoft.com/config/${ID}/${VERSION_ID}/prod.list" \ + | tee /etc/apt/sources.list.d/mssql-release.list + apt-get update -ACCEPT_EULA=Y apt-get -y install msodbcsql17 unixodbc-dev +ACCEPT_EULA=Y apt-get -y install msodbcsql18 unixodbc-dev touch ~/mssql-installed diff --git a/toucan_connectors/install_scripts/mssql_TLSv1_0.sh b/toucan_connectors/install_scripts/mssql_TLSv1_0.sh index f33c36faa..168658a66 100755 --- a/toucan_connectors/install_scripts/mssql_TLSv1_0.sh +++ b/toucan_connectors/install_scripts/mssql_TLSv1_0.sh @@ -12,25 +12,5 @@ else echo "DEFAULT@SECLEVEL=1" >> /etc/ssl/openssl.cnf fi - -if [[ -e ~/mssql-installed ]]; then - echo "MSSQL connector dependencies are already installed." - exit -fi - -apt-get update -apt-get install -fyq gnupg curl -curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - -source /etc/os-release -if [ "$ID" == "debian" ]; then - # debian/12 fails - fixing to debian/11 works: - curl "https://packages.microsoft.com/config/debian/11/prod.list" \ - | tee /etc/apt/sources.list.d/mssql-release.list -else - curl "https://packages.microsoft.com/config/${ID}/${VERSION_ID}/prod.list" \ - | tee /etc/apt/sources.list.d/mssql-release.list -fi -apt-get update -ACCEPT_EULA=Y apt-get -y install msodbcsql17 unixodbc-dev - -touch ~/mssql-installed +MSSQL_INSTALLER_PATH="$(dirname $0)/mssql.sh" +exec $MSSQL_INSTALLER_PATH diff --git a/toucan_connectors/install_scripts/oracle.sh b/toucan_connectors/install_scripts/oracle.sh index ca5f3faba..23ff863ec 100755 --- a/toucan_connectors/install_scripts/oracle.sh +++ b/toucan_connectors/install_scripts/oracle.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x set -e if [[ -e ~/oracle-installed ]]; then @@ -7,9 +7,28 @@ if [[ -e ~/oracle-installed ]]; then fi apt-get update -apt-get install -fyq libaio1 curl wget unzip + +source /etc/os-release +LIBAIO="" +if [[ "$ID" == "debian" ]]; then + LIBAIO="libaio1" + apt-get install -fyq --no-install-recommends \ + curl unzip ca-certificates "$LIBAIO" +else + # Ubuntu 24.04 migrated to 64 bits components for most libs, which does not + # work with the oracle library drivers + LIBAOI="libaio1t64" + apt-get install -fyq --no-install-recommends \ + curl unzip ca-certificates "$LIBAIO" + # WARNING: not safe: Creating a symbolic link from the 64bits version to the + # 32bits one. A better fix would probably be to switch to + # https://oracle.github.io/python-oracledb/ eventually + ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 \ + /usr/lib/x86_64-linux-gnu/libaio.so.1 +fi + mkdir -p /opt/oracle -wget 'https://public-package.toucantoco.com/connectors_sources/oracle/oracle_client_lib/instantclient-basiclite-linux.x64-12.2.0.1.0.zip' -O '/tmp/oracle_client_lib.zip' +curl -sSL 'https://public-package.toucantoco.com/connectors_sources/oracle/oracle_client_lib/instantclient-basiclite-linux.x64-12.2.0.1.0.zip' -o '/tmp/oracle_client_lib.zip' unzip /tmp/oracle_client_lib.zip -d /opt/oracle sh -c "echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf" ldconfig diff --git a/toucan_connectors/mssql/mssql_connector.py b/toucan_connectors/mssql/mssql_connector.py index 6f8305afc..6de7b1b15 100644 --- a/toucan_connectors/mssql/mssql_connector.py +++ b/toucan_connectors/mssql/mssql_connector.py @@ -108,7 +108,7 @@ def get_connection_params(self, database): if self.port is not None: server += f",{self.port}" con_params = { - "driver": "{ODBC Driver 17 for SQL Server}", + "driver": "{ODBC Driver 18 for SQL Server}", "server": server, "database": database, "user": self.user, diff --git a/toucan_connectors/mssql_TLSv1_0/mssql_connector.py b/toucan_connectors/mssql_TLSv1_0/mssql_connector.py index 85c9c8bc2..20671ff4a 100644 --- a/toucan_connectors/mssql_TLSv1_0/mssql_connector.py +++ b/toucan_connectors/mssql_TLSv1_0/mssql_connector.py @@ -108,7 +108,7 @@ def get_connection_params(self, database): if self.port is not None: server += f",{self.port}" con_params = { - "driver": "{ODBC Driver 17 for SQL Server}", + "driver": "{ODBC Driver 18 for SQL Server}", "server": server, "database": database, "user": self.user,