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(install scripts): use ODBC 18 for MSSQL and fix Oracle installation #1858

Merged
merged 2 commits into from
Dec 20, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/mssql/test_mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions tests/mssql_TLSv1_0/test_mssql_TLSv1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion toucan_connectors/azure_mssql/azure_mssql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 12 additions & 11 deletions toucan_connectors/install_scripts/mssql.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 2 additions & 22 deletions toucan_connectors/install_scripts/mssql_TLSv1_0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 22 additions & 3 deletions toucan_connectors/install_scripts/oracle.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x
set -e

if [[ -e ~/oracle-installed ]]; then
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion toucan_connectors/mssql/mssql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion toucan_connectors/mssql_TLSv1_0/mssql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading