- ADBC Drivers
- Db2
The Db2 ADBC driver
Implements the IBM DRDA wire protocol directly — no IBM CLI, no JCC, no client libraries to install. Move data between Db2 and Hardcharger bidirectionally — through ADBC in Python — streamed the whole way as Apache Arrow.
No CLI, no JCC
Implements the IBM DRDA wire protocol itself, from scratch in Go. There is no IBM Data Server Client, no JDBC/JCC jar, no native runtime to install.
Bidirectional with Hardcharger
Stream a table from Db2 into Hardcharger, or push data back through their ADBC drivers in Python. DuckDB SQL federation uses the separate adbc_scanner extension.
Pipelined & columnar
Rows pipeline many-per-DRDA-round-trip on the way in, and results come back as Arrow record batches — straight into pandas, Polars, or DuckDB.
One C API. Every language.
The examples on this page are in Python, but ADBC exposes each driver as a C-compatible shared library — so the same native core works from Go, Rust, Java, C#, C/C++, JavaScript, and more. One driver, every stack.
Get started
One pip install and a connection string. No IBM Data Server Client, no JCC jar, no native runtime to provision.
1# pip install adbc-driver-db2 — no IBM CLI, no JCC
2import adbc_driver_db2.dbapi as db2
3
4with db2.connect(uri=uri, username=user, password=pw) as conn, conn.cursor() as cur:
5 cur.execute("SELECT * FROM SYSCAT.TABLES FETCH FIRST 10 ROWS ONLY")
6 for batch in cur.fetch_record_batch():
7 print(batch)Db2 → Hardcharger in Python
Both drivers are Arrow-native, so the Db2 reader feeds Hardcharger’s bulk ingest directly. The rows stream from source to target — without collecting the full table in client memory. Reverse the connections to push the other way.
Hardcharger is just one destination. Because the reader is standard Apache Arrow, the same code streams Db2 into any ADBC-enabled target — another warehouse, DuckDB, Postgres, SQLite, or another database entirely. One interface, any source, any sink.
Set the connection environment variables first. HARDCHARGER_URI uses hardcharger://host:31337 with TLS; add ?tls=false only for a local development server. This example creates a new orders table; use mode="append" for an existing compatible table.
1# pip install adbc-driver-db2 adbc-driver-hardcharger
2import os
3import adbc_driver_db2.dbapi as db2
4import adbc_driver_hardcharger.dbapi as hardcharger
5
6with db2.connect(uri=os.environ["DB2_URI"], username=os.environ["DB2_USERNAME"], password=os.environ["DB2_PASSWORD"]) as src, \
7 hardcharger.connect(
8 uri=os.environ["HARDCHARGER_URI"],
9 username=os.environ["HARDCHARGER_USERNAME"],
10 password=os.environ["HARDCHARGER_PASSWORD"],
11 ) as dst:
12 with src.cursor() as s, dst.cursor() as d:
13 s.execute("SELECT * FROM SALES.ORDERS")
14 # Arrow batches stream directly into the destination ingest.
15 rows = d.adbc_ingest(
16 table_name="orders", data=s.fetch_record_batch(), mode="create"
17 )
18 print(f"Loaded {rows:,} rows")Query Db2 live from DuckDB
Because the driver is a standard ADBC c-shared library, DuckDB’s adbc_scanner extension can ATTACH Db2 and both read it live (with projection and filter pushdown, joining it against local data) and write back with plain SQL (USE the Db2 schema, then CREATE TABLE … AS). Credentials live in a self-contained DuckDB secret:
-- From DuckDB or GizmoSQL (which embeds DuckDB) — query Db2 live, both ways
INSTALL adbc_scanner FROM community;
LOAD adbc_scanner;
-- credentials once, in a DuckDB secret
CREATE SECRET db2_secret (
TYPE adbc,
SCOPE 'db2://db2host:50000/SAMPLE',
driver 'db2', -- registered via: python -m adbc_driver_db2 install-manifest
uri 'db2://db2host:50000/SAMPLE',
username 'db2inst1',
password '********'
);
ATTACH 'db2://db2host:50000/SAMPLE' AS db2 (TYPE adbc);
-- READ: query Db2 live (projection + filter pushdown)
SELECT * FROM db2.SALES.ORDERS WHERE ORDER_DATE >= DATE '2024-01-01';
-- join Db2 with local data without copying it first
SELECT o.ORDER_ID, c.name
FROM db2.SALES.ORDERS o
JOIN customers c ON c.id = o.CUST_ID;
-- WRITE: push straight into Db2 with plain SQL
USE db2.SALES;
CREATE TABLE ORDERS_2024 AS SELECT * FROM memory.staged_orders;This SQL example requires an adbc_scanner build compatible with your DuckDB version and platform. Existing GizmoSQL deployments can use it where supported. For Hardcharger, use the Python streaming example above.
Prefer credentials out of your SQL? adbc_scanner also resolves ADBC connection profiles (profile://…), as does Columnar’s adbc extension.
Independent reimplementation. This is an independent, from-scratch Go implementation of the DRDA protocol — an open standard published by The Open Group — built from openly-licensed references. It contains no IBM source code and links against no IBM libraries. It is not affiliated with, endorsed by, or sponsored by IBM Corporation. IBM and Db2 are trademarks of International Business Machines Corporation.
Db2 ADBC driver — FAQ
Does the Db2 ADBC driver need the IBM CLI or JCC?
No. It implements the DRDA network protocol directly in Go, so it installs with one line for every ADBC language, or with pip for Python — no IBM Data Server Client, no JCC jar, no native driver runtime.
Which Db2 platforms are supported?
Db2 for Linux/UNIX/Windows (LUW) and Db2 for i, over DRDA. It handles Db2 types including DECIMAL, VARCHAR/VARGRAPHIC, TIMESTAMP, BOOLEAN, and large objects (BLOB/CLOB).
How do I move a Db2 table into Hardcharger?
Open both connections and hand the Db2 cursor's Arrow reader to Hardcharger's adbc_ingest — the rows stream from Db2 to Hardcharger without ever landing in a dataframe or a file. It works in the other direction too.
Can I query Db2 live from DuckDB?
On DuckDB builds with a compatible adbc_scanner extension, you can ATTACH Db2 and query or write it through SQL. Existing GizmoSQL deployments can use the same approach where their DuckDB version supports it. Extension availability depends on the DuckDB version and platform. For Hardcharger, use the Python Arrow streaming example on this page.
Is this an official IBM driver?
No. It is an independent, from-scratch reimplementation of the DRDA protocol — an open standard published by The Open Group — built from openly-licensed references. It is not affiliated with, endorsed by, or sponsored by IBM Corporation; IBM and Db2 are trademarks of International Business Machines Corporation.
Ready to move your data?
Install Hardcharger for free and use ADBC drivers to stream your first table.