ibmi-python
/ibmi-python
Write Python that connects to IBM i - Db2 for i queries with mapepire-python or pyodbc, running CL commands through QSYS2.QCMDEXC, downloading source members, object and where-used lookups, and Python running in IBM i PASE. Use for any Python script, CLI or automation that talks to IBM i.
- Author
- ZodandSons ↗
- Repository
- bob-ibmi-cert-academy ↗
- Licence
- GPL-3.0
- Last repository change
- 29.10.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 1
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 29.10.2026, without references to retired models or APIs.
GPL-3.0, otwarta.
- 1 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/ibmi_tool.py
What it does and when to use it
Write Python that connects to IBM i - Db2 for i queries with mapepire-python or pyodbc, running CL commands through QSYS2.QCMDEXC, downloading source members, object and where-used lookups, and Python running in IBM i PASE. Use for any Python script, CLI or automation that talks to IBM i.
Original author description
Write Python that connects to IBM i - Db2 for i queries with mapepire-python or pyodbc, running CL commands through QSYS2.QCMDEXC, downloading source members, object and where-used lookups, and Python running in IBM i PASE. Use for any Python script, CLI or automation that talks to IBM i.
How it works
- Ready-made tool
- Choosing a connection method
- Rules for new scripts
- Handy SQL for scripts
SKILL.md preview
---
name: ibmi-python
description: Write Python that connects to IBM i - Db2 for i queries with mapepire-python or pyodbc, running CL commands through QSYS2.QCMDEXC, downloading source members, object and where-used lookups, and Python running in IBM i PASE. Use for any Python script, CLI or automation that talks to IBM i.
---
# Python for IBM i
## Ready-made tool
`scripts/ibmi_tool.py` is a working CLI (standard library + one backend). Use it directly
for quick lookups, or copy its patterns into new scripts:
```bash
pip install -r .bob/skills/ibmi-python/scripts/requirements.txt
set -a; . ./.env; set +a # DB2i_HOST / DB2i_USER / DB2i_PASS
python3 .bob/skills/ibmi-python/scripts/ibmi_tool.py objects ORDDEV01 --type "*PGM"
python3 .bob/skills/ibmi-python/scripts/ibmi_tool.py where-used ORDDEV01 CUSTMAST --format json
python3 .bob/skills/ibmi-python/scripts/ibmi_tool.py source ORDDEV01 QRPGLESRC CUSTINQ \
-o qrpglesrc/legacy/custinq.pgm.rpgle
python3 .bob/skills/ibmi-python/scripts/ibmi_tool.py query "SELECT ..." --dry-run
```
## Choosing a connection method
| Method | Runs where | Install | Notes |
|--------|-----------|---------|-------|
| `mapepire-python` | Anywhere | `pip install mapepire-python` | Needs Mapepire server on IBM i (port 8076). Preferred. |
| `pyodbc` | Anywhere | `pip install pyodbc` + IBM i Access ODBC driver | Mature, fast; driver install required |
| `ibm_db` in PASE | On IBM i | `yum install python3-ibm_db` | Local, no network credentials |
| `itoolkit` | On IBM i / remote | `pip install itoolkit` | Call programs, CL, APIs via XMLSERVICE |
## Rules for new scripts
<Steps>
<Step>
Credentials from environment variables only (`DB2i_HOST`, `DB2i_USER`, `DB2i_PASS`).
Never accept a password as a command-line argument — it lands in shell history and `ps`.
</Step>
<Step>
Parameter markers (`?`) for every value. Object and library names cannot be parameters,
so validate them with the `ibmi_name()` pattern (`^[A-Z$#@][A-Z0-9$#@_]{0,9}$`) first.
</Step>
<Step>
Use one connection per run and close it in `finally`. `QTEMP` objects (aliases, work
files) only exist for the life of that connection.
</Step>
<Step>
Make scripts safe by default: read-only unless a flag says otherwise, a `--dry-run`
that prints SQL, and refusal of destructive CL (see `BLOCKED_CL` in the tool).
</Step>
<Step>
Output formats: human table by default, `--format json` for Bob Shell / CI pipelines.
</Step>
</Steps>
## Handy SQL for scripts
- Run CL: `CALL QSYS2.QCMDEXC(?)`
- Read a source member: `CREATE ALIAS QTEMP.X FOR LIB.FILE (MBR)` then `SELECT SRCDTA ... ORDER BY SRCSEQ`
- IFS file content: `SELECT LINE FROM TABLE(QSYS2.IFS_READ(PATH_NAME => ?))`
- Spool file text: `SELECT SPOOLED_DATA FROM TABLE(SYSTOOLS.SPOOLED_FILE_DATA(JOB_NAME => ?, SPOOLED_FILE_NAME => ?))`
Files in this package (4)
- SKILL.md 3 KB
- scripts/.env.example 1 KB
- scripts/ibmi_tool.py 11 KB
- scripts/requirements.txt 1 KB
Versions
The database has no other skills named ibmi-python.
Database snapshot: 13.11.2026 · package version 4f95f0010c52 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90ibmi-platform
IBM i platform fundamentals - objects, libraries, the library list, jobs, subsystems, activation groups, CCSIDs, messages and authority. Use when a task needs IBM i system knowledge, when explaining IBM i behaviour, or when diagnosing runtime errors such as CPF/MCH/RNX/SQL messages. - 90ibmi-build
Build and compile IBM i objects from git stream-file source with TOBi, The Object Builder for i (formerly Better Object Builder; command makei) - iproj.json, .ibmi.json, Rules.mk dependencies, compiling one file or the whole project, and reading compile errors. Use when… - 100ibmi-mcp-tool-builder
Guide and build custom YAML SQL tools for the IBM i MCP Server (@ibm/ibmi-mcp-server). Covers designing the tool, discovering the right Db2 for i SQL services, prototyping and testing the SQL live on IBM i through IBM i Developer mode, writing the YAML tool file, validating it… - 95ibm-cloud
Use this skill when the user says 'ibm cloud', 'ibm cloud infrastructure', 'ibm cloud services', 'ibm cloud pak', 'ibm cloud foundry', 'ibm cloud kubernetes', 'iks', 'ibm cloud satellite', 'ibm cloud schematics', 'ibm cloud terraform', 'ibm cloud iam', 'ibm cloud vpc', 'ibm… - 100ibm-a11y-route-scan
Batch-scan Langflow frontend routes for accessibility issues using the Python IBM Equal Access scanner (scripts/a11y/a11y_scan.py) and produce JSON/Markdown/HTML reports. Scans the default-loaded state of each route only (use explicit state files for modals). Use when asked to… - 100ibm-a11y-testing-guide
Reference guide for writing and running Langflow frontend accessibility tests with axe (Jest) and IBM Equal Access (Playwright `page.runA11yScan`). Covers which engine/test layer to pick, the POUR checklist, axe-vs-IBM rule gaps, Radix/AG-Grid component gotchas, and IBM…