adbc-driver-ibm-db2
ADBC (Arrow Database Connectivity) driver for IBM Db2. It lets you run SQL against Db2 from Python and get the results back as Apache Arrow data, without converting row by row.
- Query results come back as Arrow tables, so they work directly with pandas, Polars, DuckDB and other Arrow-aware tools.
- Bulk-load Arrow data into Db2 tables with
adbc_ingest. - Standard Python DB-API 2.0 interface (
connect,cursor,execute, ...). - No separate Db2 client install is needed. The Db2 CLI libraries come from the
ibm_dbpackage, which is installed automatically.
Installation
pip install "adbc-driver-ibm-db2[dbapi]"
The [dbapi] extra installs pyarrow and pandas, which you need to fetch
results as Arrow tables or DataFrames. If you only need the driver itself:
pip install adbc-driver-ibm-db2
Requirements
- Python 3.11 or newer
- Linux (x86_64), macOS 15 or newer (Apple Silicon), or Windows (x64). Prebuilt wheels are published for each.
Quick start
import adbc_driver_ibm_db2
conn = adbc_driver_ibm_db2.connect(
"DATABASE=testdb;UID=db2user;PWD=secret;HOSTNAME=db2host;PORT=50000;PROTOCOL=TCPIP"
)
with conn.cursor() as cur:
cur.execute("SELECT 1 FROM SYSIBM.SYSDUMMY1")
print(cur.fetchone())
conn.close()
The connection string uses the standard Db2 CLI format (KEY=value; pairs).
Avoid hard-coding passwords. Read them from an environment variable or a secrets
manager instead.
Working with Arrow and pandas
These calls need the [dbapi] extra (pyarrow, and pandas for fetch_df).
import adbc_driver_ibm_db2
with adbc_driver_ibm_db2.connect(conn_str) as conn:
with conn.cursor() as cur:
cur.execute("SELECT * FROM MYSCHEMA.SALES")
table = cur.fetch_arrow_table() # pyarrow.Table
# df = cur.fetch_df() # pandas.DataFrame instead
Because the result is a standard Arrow table, you can pass it on to any
Arrow-aware library, for example polars.from_arrow(table).
Loading data into Db2
import pyarrow as pa
data = pa.table({"id": [1, 2, 3], "name": ["a", "b", "c"]})
with adbc_driver_ibm_db2.connect(conn_str) as conn:
with conn.cursor() as cur:
cur.adbc_ingest("MY_TABLE", data, mode="create")
conn.commit()
mode can be "create", "append", "replace" or "create_append".
Encrypted (SSL/TLS) connections
Pass the SSL settings through db_kwargs using DatabaseOptions:
from adbc_driver_ibm_db2 import DatabaseOptions, connect
conn = connect(
"DATABASE=testdb;UID=db2user;PWD=secret;HOSTNAME=db2host;PORT=50001;PROTOCOL=TCPIP",
db_kwargs={
DatabaseOptions.SSL_SECURITY: "SSL",
DatabaseOptions.SSL_SERVER_CERT: "/path/to/server.arm",
},
)
| Option | Meaning |
|---|---|
DatabaseOptions.SSL_SECURITY |
Set to "SSL" to turn on an encrypted connection. |
DatabaseOptions.SSL_SERVER_CERT |
Path to the server certificate (.arm). Needed for a self-signed server certificate. |
DatabaseOptions.SSL_CLIENT_KEYSTOREDB |
Path to the client key database (.kdb). |
DatabaseOptions.SSL_CLIENT_KEYSTASH |
Path to the keystore stash file (.sth). |
Type mapping notes
Some Db2 types map to Arrow types in ways you might not expect:
| Db2 type | Arrow type |
|---|---|
DECIMAL(p, s) |
string (not decimal128) |
XML |
binary |
TIMESTAMP(p) |
timestamp without a timezone |
When loading data with adbc_ingest, Arrow bool columns are created as
SMALLINT, and decimal128 columns are created as DECIMAL(31, 8).
Environment variables
| Variable | Purpose |
|---|---|
IBM_DB_HOME |
(Optional) Path to a Db2 clidriver. Found automatically from ibm_db if not set. |
ADBC_DB2_DRIVER |
(Optional) Path to a different libadbc_driver_db2 shared library to use instead of the bundled one. |
Troubleshooting
Cannot locate libadbc_driver_db2...: you are not using a binary wheel. Install from PyPI (pip install adbc-driver-ibm-db2), or setADBC_DB2_DRIVERto the library path.- Db2 CLI library not found at connect time: make sure
ibm_dbinstalled correctly (pip show ibm_db), or setIBM_DB_HOMEto yourclidriverfolder. pyarrowimport errors onfetch_arrow_table(): install the extra withpip install "adbc-driver-ibm-db2[dbapi]".
Building from source
# Build the native driver first (see the repository README), then:
pip wheel python/ -w dist/
pip install dist/adbc_driver_ibm_db2-*.whl
Links
- Source and issue tracker: https://github.com/adbc-drivers/db2
- ADBC documentation: https://arrow.apache.org/adbc/
License
Apache License 2.0.
Metadata
Release files for adbc-driver-ibm-db2 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adbc_driver_ibm_db2-1.0.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for adbc_driver_ibm_db2-1.0.0-py3-none-win_amd64.whl |
| adbc_driver_ibm_db2-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 | Details for adbc_driver_ibm_db2-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
| adbc_driver_ibm_db2-1.0.0-py3-none-macosx_15_0_arm64.whl | Python 3 | none | macOS 15.0+ ARM64 | Details for adbc_driver_ibm_db2-1.0.0-py3-none-macosx_15_0_arm64.whl |
Total release size: 995.9 kB
Release files / adbc_driver_ibm_db2-1.0.0-py3-none-win_amd64.whl
| Download URL | adbc_driver_ibm_db2-1.0.0-py3-none-win_amd64.whl |
|---|---|
| Size | 299.6 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6db943d5d2e822272fa71bacdf71c0288031df7e57cd37f91bd0e9733966c093
|
|
BLAKE2b-256 checksum How to use checksums |
2b490e39243bcaa2c58c73ab6778e0f1bd8497cbd4de66964357022e68e22d5e
|
| 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 23, 2026.
Transparency logRelease files / adbc_driver_ibm_db2-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | adbc_driver_ibm_db2-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 453.6 kB |
| Tags | Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
703a183accada8295a0fcbff00e761681a4102ecbf79bcb589efcf8907f7e62e
|
|
BLAKE2b-256 checksum How to use checksums |
aca1cff04f54bfc2d5fbd96ead357459fc8f3772ec82cf7e1e997404a4db5bb0
|
| 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 23, 2026.
Transparency logRelease files / adbc_driver_ibm_db2-1.0.0-py3-none-macosx_15_0_arm64.whl
| Download URL | adbc_driver_ibm_db2-1.0.0-py3-none-macosx_15_0_arm64.whl |
|---|---|
| Size | 242.7 kB |
| Tags | Python 3 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
04e31e9d9c8796697b9c49cf0558d913acfb7dc26c4ecde9802f30efffded5a4
|
|
BLAKE2b-256 checksum How to use checksums |
1c3657fb8a1b4446d010add068d60b4241e814ad4177c09a5db42d9b0155dafa
|
| 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 23, 2026.
Transparency logSecurity for adbc-driver-ibm-db2 1.0.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 3 files in this release have been uploaded with provenance metadata.
Attestation for adbc_driver_ibm_db2-1.0.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 23, 2026.
Transparency logA 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.