ibm-db
Python DBI driver for DB2 (LUW, zOS, i5)
What it is and what it does
ibm_db is a Python driver for IBM Db2 databases (LUW and z/OS variants) that wraps the IBM Data Server Driver for ODBC and CLI. It provides two interfaces: a native ibm_db driver for direct ODBC/CLI access, and ibm_db_dbi, a DB-API 2.0-compliant wrapper for standard Python database programming. The package is actively maintained and supports Python 3.9 through 3.14 across Linux, macOS (including ARM64 from 3.9 onwards), Windows, and Unix platforms.
Installation is straightforward via pip for most platforms—prebuilt wheels bundle the clidriver, eliminating external dependencies for typical setups. However, on Linux systems with older glibc or CPUs predating 2009, or when using an external Db2 client installation, you must build from source, which requires a GCC compiler and ODBC headers. Windows users with an existing Db2 client may need to configure the IBM_DB_HOME environment variable. The package handles Windows DLL resolution automatically via a .pth file, though manual fallback configuration is documented if needed.
Use it for:
- Connect Python applications to IBM Db2 LUW databases for transactional workloads and reporting.
- Execute SQL queries and stored procedures against Db2 z/OS mainframe databases from Python scripts.
- Build DB-API 2.0-compliant applications using ibm_db_dbi for portable Db2 access.
- Migrate legacy Db2 applications to Python while maintaining existing database infrastructure.
- Integrate Db2 data into Python data pipelines and analytics workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python driver for connecting to IBM Db2 for LUW and IBM Db2 for z/OS databases, providing both a native interface and a DB-API 2.0-compliant wrapper.
Yes. ibm_db is production-stable (Development Status 5) with no known vulnerabilities, active maintenance (released 3 days ago), and permissive Apache 2.0 licensing. Install friction is moderate but manageable for most platforms via prebuilt wheels. Choose it if you need reliable Db2 connectivity from Python; the DB-API 2.0 wrapper provides portability. Avoid if your system has glibc < 2.34 and you cannot build from source, or if you lack Db2 server/client access.
Install
ibm-db on PyPI
pip
pip install ibm-dbuv
uv add ibm-dbpoetry
poetry add ibm-dbInstalling ibm-db
Before you install
Medium install friction: prebuilt wheels available for Linux, macOS, and Windows across Python 3.9–3.14, but source builds require a GCC compiler and ODBC headers. Linux wheels require glibc >= 2.34 and x86_64-v2 CPU support; older systems must build from source. Windows users may need to set IBM_DB_HOME if a Db2 client is already installed.
License in practice
Licensed under Apache License 2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects.
Quickstart
pip install ibm_db
import ibm_db
conn = ibm_db.connect('DATABASE=mydb;HOSTNAME=localhost;PORT=port;UID=user;PWD=pass;PROTOCOL=TCPIP', '', '')
stmt = ibm_db.exec_immediate(conn, 'SELECT * FROM table')
result = ibm_db.fetch_assoc(stmt)
Requires IBM Db2 server or client connectivity; on Linux, glibc >= 2.34 and x86_64-v2 CPU support for prebuilt wheels, or GCC compiler to build from source. Windows may require IBM_DB_HOME environment variable if a Db2 client is installed.
Verify before relying
- Whether precompiled wheels include all necessary clidriver components for immediate use without external Db2 installation.
- Performance characteristics and connection pooling capabilities.
- Asyncio API maturity and feature completeness relative to the synchronous interface.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 3 days since the last release |
| First released | |
| Downloads | 4,008,623/month — #2,402 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ibm_db-3.3.0-cp310-cp310-macosx_10_15_x86_64.whl; ibm_db-3.3.0-cp310-cp310-macosx_14_0_arm64.whl; ibm_db-3.3.0-cp310-cp310-manylinux_2_34_i686.whl; ibm_db-3.3.0-cp310-cp310-manylinux_2_34_x86_64.whl; ibm_db-3.3.0-cp310-cp310-win32.whl; ibm_db-3.3.0-cp310-cp310-win_amd64.whl; ibm_db-3.3.0-cp311-cp311-macosx_10_15_x86_64.whl; ibm_db-3.3.0-cp311-cp311-macosx_14_0_arm64.whl; ibm_db-3.3.0-cp311-cp311-manylinux_2_34_i686.whl; ibm_db-3.3.0-cp311-cp311-manylinux_2_34_x86_64.whl; ibm_db-3.3.0-cp311-cp311-win32.whl; ibm_db-3.3.0-cp311-cp311-win_amd64.whl; ibm_db-3.3.0-cp312-cp312-macosx_10_15_x86_64.whl; ibm_db-3.3.0-cp312-cp312-macosx_14_0_arm64.whl; ibm_db-3.3.0-cp312-cp312-manylinux_2_34_i686.whl; ibm_db-3.3.0-cp312-cp312-manylinux_2_34_x86_64.whl; ibm_db-3.3.0-cp312-cp312-win32.whl; ibm_db-3.3.0-cp312-cp312-win_amd64.whl; ibm_db-3.3.0-cp313-cp313-macosx_10_15_x86_64.whl; ibm_db-3.3.0-cp313-cp313-macosx_14_0_arm64.whl
Keywords: database, DB-API, interface, IBM, Data, Servers, Db2
Tags
More Front-Ends packages
SQLAlchemy is a Python SQL toolkit and Object…
permissive · top 100 on PyPI
psycopg2-binarypsycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
alembicAlembic generates and manages database schema…
permissive · top 1,000 on PyPI
weaviate-clientA Python client library for connecting to and…
permissive · top 1,000 on PyPI
databricks-sql-connectorA Python client library that connects to…
permissive · top 1,000 on PyPI
psycopgPsycopg 3 is a PostgreSQL database adapter for…
copyleft · top 1,000 on PyPI
ibm-db-saSQLAlchemy dialect adapter that enables Python…
permissive · top 15,000 on PyPI
sqlalchemy-ibmiProvides a SQLAlchemy dialect to connect to Db2…
permissive · top 15,000 on PyPI
pyodbcpyodbc provides Python access to ODBC databases…
permissive · top 1,000 on PyPI
sqlalchemy-jdbcapiSQLAlchemy dialect for JDBC and ODBC database…
permissive · top 15,000 on PyPI
databricks-dbapiProvides a DBAPI 2.0 connection interface and…
permissive · top 15,000 on PyPI
aerospikePython client library for connecting to and…
permissive · top 15,000 on PyPI
JayDeBeApiJayDeBeApi bridges Python to Java JDBC database…
copyleft · top 5,000 on PyPI
sqlalchemy-firebirdProvides a SQLAlchemy 2.0+ dialect for…
permissive · top 15,000 on PyPI
pg8000pg8000 is a pure-Python PostgreSQL driver that…
permissive · top 1,000 on PyPI
mssql-python-odbcProvides platform-specific Microsoft ODBC…
unclear · top 15,000 on PyPI