Skip to main content

adbc-driver-db2 - by GizmoData™

GitHub gizmodata/adbc-driver-db2 CI Go Reference Go version Supported Python versions PyPI version PyPI downloads ADBC conformance suites passing Follows the ADBC driver style guide MIT license Works with Hardcharger

Arrow straight from IBM Db2, in Python: a pure-Go ADBC driver that speaks DRDA. No IBM client needed.

Python package for adbc-driver-db2, a pure-Go Apache Arrow ADBC driver for IBM Db2, by GizmoData™.

It speaks Db2's native wire protocol, DRDA, directly and returns Arrow record batches. No IBM CLI / ODBC driver, no db2jcc, no IBM libraries: the driver is a shared library inside the wheel.

An independent, open-source project. Not affiliated with, endorsed by, or sponsored by IBM Corporation. "IBM" and "Db2" are trademarks of International Business Machines Corporation, used here only to describe compatibility.

Status: alpha. Tested against Db2 LUW 12.1 (Community Edition).

This page covers the Python package. For other languages (C, C++, Go, Rust, R, DuckDB), the one-line installer of the shared library (curl https://install.adbc.gizmodata.com/db2 | sh), every connection option, type mapping, bulk ingest and the Hardcharger and DuckDB integrations, see the project README on GitHub.

Install

pip install adbc-driver-db2
  • Python 3.10 or later.
  • Wheels for Linux x86_64 and aarch64 (glibc 2.17 or later), macOS arm64 (13 or later) and Windows x64.
  • Depends on adbc-driver-manager and pyarrow.

For a local database, IBM's Db2 Community Edition container (x86_64, first start takes about ten minutes) gives you db2://localhost:50000/testdb as db2inst1 / password:

docker run -d --name db2 --privileged=true -p 50000:50000 \
  -e LICENSE=accept -e DB2INST1_PASSWORD=password -e DBNAME=testdb \
  icr.io/db2_community/db2

Connect and query

import adbc_driver_db2.dbapi as db2

with db2.connect(
    uri="db2://localhost:50000/testdb",
    username="db2inst1",
    password="password",
) as conn, conn.cursor() as cur:
    cur.execute("SELECT 42 AS answer, 'hello db2' AS greeting FROM SYSIBM.SYSDUMMY1")
    table = cur.fetch_arrow_table()  # a pyarrow.Table
    print(table)

The result is a pyarrow.Table: pass it to Polars, pandas, DuckDB or anything else that reads Arrow.

Parameters

import adbc_driver_db2.dbapi as db2

with db2.connect(
    uri="db2://localhost:50000/testdb",
    username="db2inst1",
    password="password",
) as conn, conn.cursor() as cur:
    cur.execute(
        "SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = ? FETCH FIRST 3 ROWS ONLY",
        parameters=("SYSCAT",),
    )
    print(cur.fetchall())

Stream large results

fetch_record_batch() returns a pyarrow.RecordBatchReader that pulls one DRDA query block at a time, so memory stays bounded however large the result is:

import adbc_driver_db2.dbapi as db2

with db2.connect(
    uri="db2://localhost:50000/testdb",
    username="db2inst1",
    password="password",
) as conn, conn.cursor() as cur:
    cur.execute("SELECT * FROM SYSCAT.COLUMNS")
    rows = 0
    for batch in cur.fetch_record_batch():
        rows += batch.num_rows
    print(rows)

Load the driver by name (driver manifest)

ADBC driver manifests let the ADBC driver manager, and connection profiles, find a driver by name. The package writes one for its own library:

$ python -m adbc_driver_db2 install-manifest
Wrote ADBC driver manifest: .../etc/adbc/drivers/db2.toml

Then the driver manager resolves db2:// URLs with no import of adbc_driver_db2:

from adbc_driver_manager import dbapi

with dbapi.connect(
    uri="db2://localhost:50000/testdb",
    db_kwargs={"username": "db2inst1", "password": "password"},
) as conn, conn.cursor() as cur:
    cur.execute("SELECT 1 AS one FROM SYSIBM.SYSDUMMY1")
    print(cur.fetch_arrow_table())

Options

Driver options go in db_kwargs; adbc_driver_db2.DatabaseOptions names them all. They follow the ADBC driver style guide: db2.*, with query behaviour under db2.query.* and bulk ingest under db2.ingest.*.

import adbc_driver_db2.dbapi as db2
from adbc_driver_db2 import DatabaseOptions

with db2.connect(
    uri="db2://localhost:50000/testdb",
    username="db2inst1",
    password="password",
    db_kwargs={
        DatabaseOptions.BATCH_SIZE.value: "10000",  # "db2.query.batch_rows"
        DatabaseOptions.CURRENT_SCHEMA.value: "SYSCAT",  # "db2.session.current_schema"
    },
) as conn, conn.cursor() as cur:
    cur.execute("SELECT COUNT(*) AS n FROM TABLES")
    print(cur.fetchone())

Version 0.3.0 renamed the options (adbc.db2.batch_size is now db2.query.batch_rows, and so on; the project README has the full list). The old names still work, and the first use of each writes one deprecation line to stderr.

More

Licensed under the MIT License.


GizmoData™
Built by GizmoData™, makers of Hardcharger™. Free and open source.

Hardcharger™ and GizmoData™ are trademarks of GizmoData LLC. IBM and Db2 are trademarks of International Business Machines Corporation.

Metadata

Release files for adbc-driver-db2 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for adbc-driver-db2 0.3.1
File Actions
adbc_driver_db2-0.3.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for adbc_driver_db2-0.3.1-py3-none-win_amd64.whl
adbc_driver_db2-0.3.1-py3-none-manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for adbc_driver_db2-0.3.1-py3-none-manylinux2014_x86_64.whl
adbc_driver_db2-0.3.1-py3-none-manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for adbc_driver_db2-0.3.1-py3-none-manylinux2014_aarch64.whl
adbc_driver_db2-0.3.1-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for adbc_driver_db2-0.3.1-py3-none-macosx_13_0_arm64.whl

Total release size: 32.0 MB

Release files / adbc_driver_db2-0.3.1-py3-none-win_amd64.whl

Download URL adbc_driver_db2-0.3.1-py3-none-win_amd64.whl
Size 9.5 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
0d39b10851a9b86aae49b39f14ae1673f78ccead22d32f42c86b2f66154de9c3
BLAKE2b-256 checksum
How to use checksums
48c3edd34844b16a9f164205892792a942628f05d20af0e7457c2a23c58b23f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / adbc_driver_db2-0.3.1-py3-none-manylinux2014_x86_64.whl

Download URL adbc_driver_db2-0.3.1-py3-none-manylinux2014_x86_64.whl
Size 9.4 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
120d62a8ca6a5fcdbff349b868cf0a8c194c8ac12677a87d24ed4eb6d52d05f7
BLAKE2b-256 checksum
How to use checksums
bd3343bc2a3e75d020a0d58059bfaec36785349641a2ef92ef55489dd866b6a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / adbc_driver_db2-0.3.1-py3-none-manylinux2014_aarch64.whl

Download URL adbc_driver_db2-0.3.1-py3-none-manylinux2014_aarch64.whl
Size 8.5 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
8fe9c1f63071592bfab3177c819e36b7257e52dfe8413f31280e65e847fd915d
BLAKE2b-256 checksum
How to use checksums
a649021a37b7bd9dc9073ba9583c50f6a729e484f9cfd573421a7295b412cbce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / adbc_driver_db2-0.3.1-py3-none-macosx_13_0_arm64.whl

Download URL adbc_driver_db2-0.3.1-py3-none-macosx_13_0_arm64.whl
Size 4.6 MB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
677bf625c24b5862d7bbb4ac9934d438d80c1b04d964e1efef0b433206eb94bc
BLAKE2b-256 checksum
How to use checksums
ed661ed48f291541310d39aff78a7af87cdb741d3cbc971649801373fedf7cc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for adbc-driver-db2 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for adbc_driver_db2-0.3.1-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page