A very simple asynchronous wrapper that allows you to get access to the Oracle database in asyncio programs.
A very simple asynchronous wrapper that allows you to get access to the Oracle database in asyncio programs.
Easy to use , buy may not the best practice for efficiency concern.
In parallel with the main branch, we have worked on a development version based on SQLAlchemy’s thread pool management facilities, please refer to Development notes for details.
pip install cx_Oracle_async
https://cx_oracle_async.readthedocs.io
query type | asynchronous multithreading | synchronous multithreading | synchronous single thread |
---|---|---|---|
fast single line query | 6259.80 q/s | 28906.93 q/s | 14805.61 q/s |
single line insertion | 1341.88 q/s | 1898 q/s | 1685.17 q/s |
/* Test platform: */
AMD Ryzen 3700x
Windows 10 LTSC
Oracle 19c
You can find performance test codes here.
Before running examples , make sure you’ve already installed a Oracle Client on your machine.
# basic_usages.py
import asyncio
import cx_Oracle_async
async def main():
oracle_pool = await cx_Oracle_async.create_pool(
host='localhost',
port='1521',
user='user',
password='password',
service_name='orcl',
min = 2,
max = 4,
)
async with oracle_pool.acquire() as connection:
async with connection.cursor() as cursor:
await cursor.execute("SELECT * FROM V$SESSION")
print(await cursor.fetchall())
await oracle_pool.close()
if __name__ == '__main__':
asyncio.run(main())