This implementation adds support for IBM DB2 for i (formerly AS/400, iSeries, System i) using the pyodbc driver with the IBM i Access ODBC Driver. This solution does not require an IBM license as it uses the freely available IBM i Access ODBC Driver.
Location: sqlit/domains/connections/providers/db2i/
adapter.py- Main adapter implementation using pyodbcprovider.py- Provider registrationschema.py- Connection schema definitionREADME.md- Comprehensive documentationexample.py- Usage examples__init__.py- Package initialization
The adapter provides full support for:
✅ Connection Management
- Connect using IBM i Access ODBC Driver (no license required)
- Support for custom ODBC driver names
- Optional port specification
- Default library/schema configuration
- Extra ODBC connection options
✅ Schema Operations
- List libraries (equivalent to databases)
- Browse tables and views
- View column definitions with data types
- Inspect primary keys
- View indexes (with uniqueness indicators)
- View triggers
- View sequences
- List stored procedures
✅ Query Execution
- Execute SQL queries
- Handle result sets
- Row limiting support
- Cross-library queries
The adapter queries these IBM i system catalogs:
QSYS2.SYSTABLES- Tables and views metadataQSYS2.SYSVIEWS- View definitionsQSYS2.SYSCOLUMNS- Column informationQSYS2.SYSROUTINES- Stored procedures/functionsQSYS2.SYSINDEXES- Index metadataQSYS2.SYSTRIGGERS- Trigger definitionsQSYS2.SYSSEQUENCES- Sequence objectsQSYS2.SYSCST- Constraints (for primary keys)
Added to pyproject.toml:
[project.optional-dependencies]
db2i = ["pyodbc>=5.0.0"]Also included in the all extras group.
Test Files Created:
tests/fixtures/db2i.py- Test fixtures for DB2 for itests/test_db2i.py- Integration tests
Test Configuration: Environment variables for testing:
DB2I_HOST- IBM i server hostnameDB2I_PORT- Optional port (if required)DB2I_USER- Username for authenticationDB2I_PASSWORD- PasswordDB2I_LIBRARY- Default library/schemaDB2I_ODBC_DRIVER- ODBC driver name (optional)
Run tests with: pytest -m db2i
{
"name": "my_ibm_i",
"db_type": "db2i",
"host": "ibmi.example.com",
"username": "myuser",
"password": "mypass",
"database": "MYLIB" # Default library
}{
"name": "my_ibm_i",
"db_type": "db2i",
"host": "ibmi.example.com",
"username": "myuser",
"password": "mypass",
"extra_options": {
"odbc_driver": "iSeries Access ODBC Driver"
}
}db2i://username:password@hostname/library
- Download IBM i Access Client Solutions
- Install the ODBC driver component
- Verify: The driver should be named "IBM i Access ODBC Driver"
- Download IBM i Access ODBC Driver for Linux
- Follow distribution-specific installation
- Verify:
odbcinst -q -d
- Download and install IBM i Access ODBC Driver
- Driver is automatically registered
# Install with DB2 for i support
pip install sqlit-tui[db2i]
# Or install all database drivers
pip install sqlit-tui[all]
# Or just install pyodbc separately
pip install pyodbcBase Class: CursorBasedAdapter
Properties:
name: "IBM DB2 for i"install_extra: "db2i"install_package: "pyodbc"driver_import_names: ("pyodbc",)supports_multiple_databases: False (uses libraries instead)supports_cross_database_queries: Truesupports_stored_procedures: Truesupports_sequences: True
DRIVER={IBM i Access ODBC Driver};
SYSTEM=hostname;
UID=username;
PWD=password;
DBQ=library;
[additional options]
- Libraries vs Databases: IBM i uses libraries as the primary organizational unit
- System Catalogs: Uses QSYS2 schema instead of SYSCAT
- ODBC-Based: Uses standard ODBC instead of DB2 CLI
- No License Required: The ODBC driver is freely available from IBM
The DB2 for i provider follows the same pattern as other database providers:
- Provider Registration: Auto-discovered via
provider.py - Schema Definition: Connection fields defined in
schema.py - Adapter Implementation: Database operations in
adapter.py - Testing: Standard test fixtures and integration tests
To use the new DB2 for i adapter:
- Ensure the IBM i Access ODBC Driver is installed on your system
- Install sqlit with DB2i support:
pip install sqlit-tui[db2i] - Create a connection configuration with
db_type="db2i" - Connect to your IBM i server!
-
sqlit/domains/connections/providers/db2i/ (new directory)
__init__.pyadapter.pyprovider.pyschema.pyREADME.mdexample.py
-
pyproject.toml
- Added
db2i = ["pyodbc>=5.0.0"]to optional dependencies - Added
pyodbc>=5.0.0toallextras
- Added
-
tests/fixtures/db2i.py (new file)
- Test fixtures for DB2 for i connections
-
tests/test_db2i.py (new file)
- Integration tests for DB2 for i
-
tests/conftest.py
- Added import for DB2i fixtures
This implementation uses:
- pyodbc: MIT License
- IBM i Access ODBC Driver: Freely available from IBM, no license fee required
The IBM i Access ODBC Driver can be downloaded from IBM at no cost and does not require purchasing an IBM DB2 license.