Skip to content

Add asyncio support, cursor enhancements, test runner refactor and documentation#1060

Open
Earammak wants to merge 1 commit intoibmdb:masterfrom
Earammak:asynciosupportpr
Open

Add asyncio support, cursor enhancements, test runner refactor and documentation#1060
Earammak wants to merge 1 commit intoibmdb:masterfrom
Earammak:asynciosupportpr

Conversation

@Earammak
Copy link
Copy Markdown
Collaborator

@Earammak Earammak commented May 7, 2026

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.

…cumentation

Signed-off-by: Earamma K <ek@rocketsoftware.com>
@Earammak Earammak requested review from bchoudhary6415 and bimalkjha and removed request for bchoudhary6415 May 7, 2026 14:04
@bchoudhary6415 bchoudhary6415 linked an issue May 8, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for AsyncIO

1 participant