oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
308 stars 61 forks source link

python-oracledb support for asyncio #258

Closed anthony-tuininga closed 6 months ago

anthony-tuininga commented 7 months ago

Good news! A prototype of python-oracledb asyncio support is on branch asyncio-support.

We are soliciting your feedback - please add comments to Issue #6.

The timeline for a production release is dependent on your testing and evaluation comments.

The new async API is part of the existing oracledb module. Any database call which needs a round-trip to the DB now has an async counterpart. (This means your code can choose whether to use the previous API or the new async API. We suggest applications in general don't use both at the same time!)

Only Thin mode supports asyncio. There are no plans to implement it in Thick mode. All DB versions that Thin mode connects to can be used, i.e. 12.1+.

Samples are in samples/*_async.py. Tests are in tests/*_async.py.

Note connection is via new methods connect_async() and create_pool_async(). There are also new class names AsyncConnectionPool, AsyncCursor, AsyncConnection, and AsyncLOB.

You can build the driver using the steps in Installing from Source Code:

git clone --recurse-submodules https://github.com/oracle/python-oracledb.git
cd python-oracledb
git checkout asyncio-support
python setup.py build
python setup.py install

One open question is whether we should simplify statement execution and remove explicit cursor usage. Instead the driver could have connection.execute() or perhaps connection.fetchone/many/all() calls. But this would need some new alternative to cursor.var() etc.

Some tasks to be done:

cjbj commented 6 months ago

Python-oracledb 2.0 has been released with asyncio support. We are still denoting the new asyncio APIs as 'pre-release' to give us some leeway if you uncover things we can improve.

Release announcement blog post: https://cjones-oracle.medium.com/python-oracledb-2-0-has-asyncio-support-2b913e40f9ca