Skip to content

pyodbc.pyi tweaks

pyodbc.pyi tweaks #269

Workflow file for this run

name: Ubuntu build
on: [push, pull_request]
jobs:
run_tests:
name: Run tests on Python ${{ matrix.python-version }}
# ubuntu-20.04 supports more versions of Python than ubuntu-22.04
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
services:
mssql2017:
image: mcr.microsoft.com/mssql/server:2017-latest
ports:
- 1401:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: StrongPassword2017
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
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:
- 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
run: |
echo "*** apt-get install the driver"
sudo ACCEPT_EULA=Y apt-get install --yes msodbcsql18
echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc'
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: 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 2017"
docker exec -i "${{ job.services.mssql2017.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2017' -Q "SELECT @@VERSION" || sleep 5
docker exec -i "${{ job.services.mssql2017.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2017' -Q "CREATE DATABASE test"
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"
- 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.1.1
- 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"
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Build and install pyodbc
run: |
cd "$GITHUB_WORKSPACE"
echo "*** current python version"
python -VV
echo "*** pip install"
python -m pip install .
echo "*** pip freeze"
python -m pip freeze --all
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 2017 tests
env:
PYODBC_SQLSERVER: "DRIVER={ODBC Driver 17 for SQL Server};SERVER=localhost,1401;UID=sa;PWD=StrongPassword2017;DATABASE=test"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/sqlserver_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"