Add asyncio support, cursor enhancements, test runner refactor and documentation#1060
Open
Earammak wants to merge 1 commit intoibmdb:masterfrom
Open
Add asyncio support, cursor enhancements, test runner refactor and documentation#1060Earammak wants to merge 1 commit intoibmdb:masterfrom
Earammak wants to merge 1 commit intoibmdb:masterfrom
Conversation
…cumentation Signed-off-by: Earamma K <ek@rocketsoftware.com>
bimalkjha
requested changes
May 8, 2026
| def run_test_01(self): | ||
| async def main(): | ||
| # Cataloged connection | ||
| conn = await ibm_db_dbi.connect_async(config.database, config.user, config.password) |
Member
There was a problem hiding this comment.
@Earammak If user or password are not in config file, check env vars DB2_USER and DB2_PASSWD for these values and if set, use it. Having password in config file is not recommended but it is an option based on users risk. Recommended way is to set DB2_PASSWD env var and ibm_db should be able to check that env var value with high priority. If env var is not set, then only use the value from config.json file.
Collaborator
Author
There was a problem hiding this comment.
The config.py.sample already handles this. It checks DB2_USER and DB2_PASSWD environment variables first and only falls back to config.json values if the environment variables aren't set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added asyncio support to python-ibmdb, enabling async/await usage for DB2 database operations via the DB-API 2.0 layer (ibm_db_dbi). All async support uses asyncio.to_thread() to offload blocking CLI calls to a thread pool — no changes to the C extension were required.
Enhancements to Cursor:
Added prepare(operation) to pre‑compile SQL statements for later execution.
Introduced bind_param(index, value, …) for binding parameters to prepared statements.
New fetch_callproc() method to retrieve stored procedure output parameters.
New fetch_tuple() method to fetch rows as tuples.
Updated execute() to support invocation without arguments after using prepare() and bind_param().
Test Runner Improvements (ibmdb_tests.py)
Refactored runner with CLI flags:
--async runs only async tests
--sync runs only sync tests
--test runs a single test file
Added _load_async_tests() to discover and execute tests from asyncio_testsuite.
Default behavior runs both sync and async suites together.
Legacy support for SINGLE_PYTHON_TEST environment variable retained.
Bug Fixes (testfunctions.py):
Fixed operator precedence in assert_expect() / assert_expectf() to ensure consistent behavior on z/OS and OS/390.
Path‑independent matching with os.path.basename() instead of hardcoded prefixes.
Replaced fragile manual regex escaping with re.escape(), removing Python version checks.
DSN connection now supports uncataloged databases when config.hostname is set.
Db2connect.enter() now correctly passes stored credentials to ibm_db.connect().
Updated entry points from python tests.py to python ibmdb_tests.py in run_all_tests and run_individual_tests.
Documentation:
ASYNC_APIs_WIKI.md: Comprehensive API reference with signatures, parameters, return values, and usage examples for all async APIs.
README.md: Added link to async API documentation.
Consolidated and updated Testing section with new CLI flags (--async, --sync, --test ), including usage examples for running sync, async, or single tests.