cx_Oracle_async icon indicating copy to clipboard operation
cx_Oracle_async copied to clipboard

Create connection without pool

Open sinys15 opened this issue 4 years ago • 3 comments

It it possible to use cx_Oracle_async without oracle pool and threads?

sinys15 avatar Oct 14 '21 07:10 sinys15

It was not designed with a direct connection mode, which may be a result of design oversight on my part, as I believe there is no proper scenario for single connection at that time. Improvements are welcomed with pull request!

GoodManWEN avatar Apr 15 '22 19:04 GoodManWEN

There is a scenario when you need async connections in SYS_DBA mode which is supported only for single connections, not for pools.

Ezhvsalate avatar Dec 17 '22 16:12 Ezhvsalate

i need to wrap all my db objects so that they maintain the same interfaces ie db.exec("select..."). it seems to work just doing something like:

connection = await cx_Oracle_async.create_pool(
    user=self.username,
    password=self.password,
    dsn=self.dsn,
)
conn = await connection.acquire()
cursor = await conn.cursor()


cursor.execute("SELECT...")
records = cursor.fetchall()


await connection.close(force=True)
connection = None
cursor = None

@GoodManWEN is there any reason to not use it like this?

WilliamStam avatar Jul 06 '23 13:07 WilliamStam