Make driver_completion configurable #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Ubuntu build | |
| # include "workflow_dispatch" so this workflow can be run manually from the Actions portal | |
| on: [push, pull_request, workflow_dispatch] | |
| jobs: | |
| run_tests: | |
| name: Run tests on Python ${{ matrix.python-version }} | |
| # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| services: | |
| mssql2019: | |
| image: mcr.microsoft.com/mssql/server:2019-latest | |
| ports: | |
| - 1402:1433 | |
| env: | |
| ACCEPT_EULA: Y | |
| SA_PASSWORD: StrongPassword2019 | |
| mssql2022: | |
| image: mcr.microsoft.com/mssql/server:2022-latest | |
| ports: | |
| - 1403:1433 | |
| env: | |
| ACCEPT_EULA: Y | |
| SA_PASSWORD: StrongPassword2022 | |
| mssql2025: | |
| image: mcr.microsoft.com/mssql/server:2025-latest | |
| ports: | |
| - 1404:1433 | |
| env: | |
| ACCEPT_EULA: Y | |
| SA_PASSWORD: StrongPassword2025 | |
| postgres: | |
| image: postgres:13 | |
| env: | |
| POSTGRES_DB: postgres_db | |
| POSTGRES_USER: postgres_user | |
| POSTGRES_PASSWORD: postgres_pwd | |
| ports: | |
| - 5432:5432 | |
| # needed because the postgres container does not provide a healthcheck | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| # to ensure the drivers are installed correctly with apt-get | |
| - name: apt-get update | |
| run: sudo apt-get update | |
| - name: Start MySQL service | |
| run: | | |
| sudo systemctl start mysql.service | |
| - name: Check initial setup | |
| run: | | |
| echo '*** echo $PATH' | |
| echo "$PATH" | |
| echo "*** odbcinst -j" | |
| odbcinst -j | |
| echo '*** ls -l /etc/odbc*.ini' | |
| ls -l /etc/odbc*.ini || true | |
| echo "*** cat /etc/odbcinst.ini" | |
| cat /etc/odbcinst.ini | |
| echo "*** cat /etc/odbc.ini" | |
| cat /etc/odbc.ini | |
| - name: Install ODBC driver for SQL Server | |
| # version 18.6.1.1-1 causes a segmentation fault in _test_tvp() for MS SQL Server, hence use the earlier version | |
| run: | | |
| echo "*** apt-get install the driver" | |
| sudo ACCEPT_EULA=Y apt-get install --yes msodbcsql18=18.5.1.1-1 | |
| echo '*** ls -l /opt/microsoft/msodbcsql18/lib64' | |
| ls -l /opt/microsoft/msodbcsql18/lib64 || true | |
| - name: Install ODBC driver for PostgreSQL | |
| run: | | |
| echo "*** apt-get install the driver" | |
| sudo apt-get install --yes odbc-postgresql | |
| echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc' | |
| ls -l /usr/lib/x86_64-linux-gnu/odbc || true | |
| echo '*** add full paths to Postgres .so files in /etc/odbcinst.ini' | |
| sudo sed -i 's|Driver=psqlodbca.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so|g' /etc/odbcinst.ini | |
| sudo sed -i 's|Driver=psqlodbcw.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so|g' /etc/odbcinst.ini | |
| sudo sed -i 's|Setup=libodbcpsqlS.so|Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so|g' /etc/odbcinst.ini | |
| - name: Install ODBC driver for MySQL | |
| run: | | |
| cd "$RUNNER_TEMP" | |
| echo "*** download driver zip file" | |
| curl --silent --show-error --write-out "$CURL_OUTPUT_FORMAT" -O "https://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/Connector-ODBC/8.0/${MYSQL_DRIVER}.tar.gz" | |
| ls -l "${MYSQL_DRIVER}.tar.gz" | |
| tar -xz -f "${MYSQL_DRIVER}.tar.gz" | |
| echo "*** copy driver file to /usr/lib" | |
| sudo cp -v "${MYSQL_DRIVER}/lib/libmyodbc8a.so" /usr/lib/x86_64-linux-gnu/odbc/ | |
| sudo chmod a+r /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so | |
| echo "*** create odbcinst.ini entry" | |
| echo '[MySQL ODBC 8.0 ANSI Driver]' > mysql_odbcinst.ini | |
| echo 'Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so' >> mysql_odbcinst.ini | |
| echo 'UsageCount = 1' >> mysql_odbcinst.ini | |
| echo 'Threading = 2' >> mysql_odbcinst.ini | |
| sudo odbcinst -i -d -f mysql_odbcinst.ini | |
| env: | |
| CURL_OUTPUT_FORMAT: '%{http_code} %{filename_effective} %{size_download} %{time_total}\n' | |
| MYSQL_DRIVER: mysql-connector-odbc-8.0.22-linux-glibc2.12-x86-64bit | |
| - name: Install ODBC driver for SQLite3 | |
| run: | | |
| echo "*** apt-get install the driver" | |
| sudo apt-get install --yes libsqliteodbc | |
| - name: Check ODBC setup | |
| run: | | |
| echo "*** odbcinst -j" | |
| odbcinst -j | |
| echo "*** cat /etc/odbcinst.ini" | |
| cat /etc/odbcinst.ini | |
| echo "*** cat /etc/odbc.ini" | |
| cat /etc/odbc.ini | |
| echo '*** ls -l /opt/microsoft/msodbcsql17/lib64' | |
| ls -l /opt/microsoft/msodbcsql17/lib64 || true | |
| echo '*** ls -l /opt/microsoft/msodbcsql18/lib64' | |
| ls -l /opt/microsoft/msodbcsql18/lib64 || true | |
| echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc' | |
| ls -l /usr/lib/x86_64-linux-gnu/odbc || true | |
| - name: Create test databases in SQL Server | |
| run: | | |
| echo "*** SQL Server 2019" | |
| docker exec -i "${{ job.services.mssql2019.id }}" /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2019' -C -Q "SELECT @@VERSION" || sleep 5 | |
| docker exec -i "${{ job.services.mssql2019.id }}" /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2019' -C -Q "CREATE DATABASE test" | |
| echo "*** SQL Server 2022" | |
| docker exec -i "${{ job.services.mssql2022.id }}" /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2022' -C -Q "SELECT @@VERSION" || sleep 5 | |
| docker exec -i "${{ job.services.mssql2022.id }}" /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2022' -C -Q "CREATE DATABASE test" | |
| echo "*** SQL Server 2025" | |
| docker exec -i "${{ job.services.mssql2025.id }}" /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2025' -C -Q "SELECT @@VERSION" || sleep 5 | |
| docker exec -i "${{ job.services.mssql2025.id }}" /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2025' -C -Q "CREATE DATABASE test" | |
| - name: Create test database in PostgreSQL | |
| run: | | |
| echo "*** get version" | |
| psql -c "SELECT version()" | |
| echo "*** create database" | |
| psql -c "CREATE DATABASE test WITH encoding='UTF8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8'" | |
| echo "*** list databases" | |
| psql -l | |
| env: | |
| PGHOST: localhost | |
| PGPORT: 5432 | |
| PGDATABASE: postgres_db | |
| PGUSER: postgres_user | |
| PGPASSWORD: postgres_pwd | |
| - name: Create test database in MySQL | |
| run: | | |
| echo "*** get status" | |
| mysql --user=root --password=root --execute "STATUS" | |
| echo "*** create database" | |
| mysql --user=root --password=root --execute "CREATE DATABASE test" | |
| - uses: actions/checkout@v4.3.0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5.0.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| allow-prereleases: true | |
| - name: Install Python dev dependencies | |
| # pyodbc doesn't have any Python dependencies, but we do need pytest for testing. | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| echo "*** upgrade pip" | |
| python -m pip install --upgrade pip | |
| echo "*** pip install dev requirements" | |
| if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi | |
| echo "*** pip freeze" | |
| python -m pip freeze --all | |
| - name: Build and install pyodbc | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| echo "*** current python version" | |
| python -VV | |
| echo "*** pip install pyodbc" | |
| CPPFLAGS=-UNDEBUG python -m pip install --verbose . | |
| echo "*** pyodbc version" | |
| python -c "import pyodbc; print(pyodbc.version)" | |
| echo "*** pyodbc drivers" | |
| python -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))" | |
| - name: Run PostgreSQL tests | |
| env: | |
| PYODBC_POSTGRESQL: "DRIVER={PostgreSQL Unicode};SERVER=localhost;PORT=5432;UID=postgres_user;PWD=postgres_pwd;DATABASE=test" | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| python -m pytest "./tests/postgresql_test.py" | |
| - name: Run MySQL tests | |
| env: | |
| PYODBC_MYSQL: "DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;UID=root;PWD=root;DATABASE=test;CHARSET=utf8mb4" | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| python -m pytest "./tests/mysql_test.py" | |
| - name: Run SQL Server 2019 tests | |
| env: | |
| PYODBC_SQLSERVER: "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1402;UID=sa;PWD=StrongPassword2019;DATABASE=test;Encrypt=Optional" | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| python -m pytest "./tests/sqlserver_test.py" | |
| - name: Run SQL Server 2022 tests | |
| env: | |
| PYODBC_SQLSERVER: "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1403;UID=sa;PWD=StrongPassword2022;DATABASE=test;Encrypt=Optional" | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| python -m pytest "./tests/sqlserver_test.py" | |
| - name: Run SQL Server 2025 tests | |
| env: | |
| PYODBC_SQLSERVER: "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1404;UID=sa;PWD=StrongPassword2025;DATABASE=test;Encrypt=Optional" | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| python -m pytest "./tests/sqlserver_test.py" | |
| - name: Run SQLite tests | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| python -m pytest "./tests/sqlite_test.py" |