python-oracledb icon indicating copy to clipboard operation
python-oracledb copied to clipboard

python-oracledb 2.0 has been released with asyncio support

Open cjbj opened this issue 2 years ago • 11 comments

python-oracledb 2.0 is here !

The main changes are:

  • Support for asynchronous concurrent coding
  • Support for ‘Success With Info’ warnings
  • Support for configuring the SDU in Thin mode
  • The future oracledb.__future__.old_json_col_as_obj has been removed
  • New Connection object attributes
  • New SQL Domain and Annotation attributes
  • Some obsolete, long deprecated parameters like encoding and nencoding have been desupported
  • Support for the obsolete Python 3.6 release has been dropped

Check out the release announcement blog post .

cjbj avatar Dec 20 '23 02:12 cjbj

just noticed a typo: connect_async should return a AsyncConnection (I was about to open a PR but it did not seem worth it to create an oracle account to sign the oca just for it)

CaselIT avatar Dec 21 '23 20:12 CaselIT

@CaselIT do you mean the typo "The pool_class parameter is expected to be a AsyncConnectionPool Object or a subclass of AsyncConnectionPool." here ?

cjbj avatar Dec 21 '23 22:12 cjbj

No this one: https://github.com/oracle/python-oracledb/blob/9645d4f9b3fb196925ac364e6dec3ab953fca222/src/oracledb/connection.py#L1750

the function connect_async returns a Connection, but should return an AsyncConnection

CaselIT avatar Dec 21 '23 22:12 CaselIT

Thanks. And thanks for the thick-mode error comment. (I'm glad we called asyncio support a 'pre-release' in this version!) I'll leave these issues to @anthony-tuininga to resolve when he's back online.

cjbj avatar Dec 21 '23 22:12 cjbj

yeah creating an async connection pool with oracledb.create_pool_async returns an asyncconnectionpool, but then returns synchronous Connection objects from pool.aquire(), of which i tried to change with connectiontype=oracledb.AsyncConnection when creating the pool, but then I get a type error

Argument of type "type[AsyncConnection]" cannot be assigned to parameter "connectiontype" of type "type[Connection]" in function "create_pool_async" "type[AsyncConnection]" is incompatible with "type[Connection]" Type "type[AsyncConnection]" cannot be assigned to type "type[Connection]"PylancereportGeneralTypeIssues

not really sure how this got into even pre-release when the default base use case does not work... also unsure as to why an async connection pool acquires sync connection objs by default if this is the intended behavior

basically:

connect_async should return AsyncConnection async_pool.acquire should return AsyncConnection

WolfEYc avatar Dec 27 '23 17:12 WolfEYc

In my case the driver worked fine, it's just the typing that have a typo. At runtime everything works in my test

CaselIT avatar Dec 27 '23 17:12 CaselIT

ok, good to hear, they just need to fix the typing then we are all good!

WolfEYc avatar Dec 27 '23 17:12 WolfEYc

I just pushed the corrections to the typing declarations.

anthony-tuininga avatar Jan 02 '24 15:01 anthony-tuininga

image still improper typing on pool.aquire(),

as well as async connection pool just hangs indefinitley, despite having so right now i just create and drop connection per request (gross).

WolfEYc avatar Feb 07 '24 21:02 WolfEYc

@WolfEYc, the first issue I can take a look at. The second issue, however, is very vague. I am able to make use of an async connection pool without hanging and I don't have to drop/create a connection each time either. Can you file a new issue and provide details of your scenario so that I can look into it further? Thanks!

anthony-tuininga avatar Feb 07 '24 22:02 anthony-tuininga

This issue is intended as an announcement. Please log any new issues separately instead of commenting here. Thank you!

anthony-tuininga avatar Feb 07 '24 22:02 anthony-tuininga