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.0

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.0
File Actions
adbc_driver_db2-0.3.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for adbc_driver_db2-0.3.0-py3-none-win_amd64.whl
adbc_driver_db2-0.3.0-py3-none-manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for adbc_driver_db2-0.3.0-py3-none-manylinux2014_x86_64.whl
adbc_driver_db2-0.3.0-py3-none-manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for adbc_driver_db2-0.3.0-py3-none-manylinux2014_aarch64.whl
adbc_driver_db2-0.3.0-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for adbc_driver_db2-0.3.0-py3-none-macosx_13_0_arm64.whl

Total release size: 32.0 MB

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

Download URL adbc_driver_db2-0.3.0-py3-none-win_amd64.whl
Size 9.5 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
012eaab9b22d5b40b9937c8405539808f87ba831191a264daca484e25a1edf3e
BLAKE2b-256 checksum
How to use checksums
75c7534809a0afb1ac96604675bb59dbdafa8581970516c9396c364f4beecec4
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 20, 2026.

Transparency log

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

Download URL adbc_driver_db2-0.3.0-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
f0221b683e3645757df2019d69192c1595916a444886528a0614609a80ee2081
BLAKE2b-256 checksum
How to use checksums
bab6c956cc65823b8140a64073e38d85b67128dbe007d1d8f8fd93d71657ff4b
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 20, 2026.

Transparency log

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

Download URL adbc_driver_db2-0.3.0-py3-none-manylinux2014_aarch64.whl
Size 8.5 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
aa23d6df75ea5c5be9b7966a54863af8108dbf515fb71f241ca968306ebc8e46
BLAKE2b-256 checksum
How to use checksums
aa222846437b895e0882a6861ce868c30f97a925381fac59a8a4f2308d1d92d7
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 20, 2026.

Transparency log

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

Download URL adbc_driver_db2-0.3.0-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
ad520d9d2d43ff2de0983aa5573c01a7fc0d0898d7ad2c2e3153f205652b415b
BLAKE2b-256 checksum
How to use checksums
72ce24a1b8997f18c4b5388c71db41d040be8e1826e508fc768ddfefcb174029
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 20, 2026.

Transparency log

Security for adbc-driver-db2 0.3.0

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.0-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 20, 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