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
337 stars 67 forks source link

ConnectionPool ignores connectiontype parameter with externalauth=False #404

Open ancc opened 3 weeks ago

ancc commented 3 weeks ago
  1. What versions are you using?

2.4.1

Give your database version. 19.11.0.0.0

Also run Python and show the output of:

import sys
import platform

print("platform.platform:", platform.platform())
print("sys.maxsize > 2**32:", sys.maxsize > 2**32)
print("platform.python_version:", platform.python_version())

platform.platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.28 sys.maxsize > 2**32: True platform.python_version: 3.9.5

And:

import oracledb
print("oracledb.__version__:", oracledb.__version__)

oracledb.version: 2.4.1

  1. Is it an error or a hang or a crash? error

  2. What error(s) or behavior you are seeing? Creating custom Connection class is not used by connectionpool when specifying externalauth=False Tried also creating custom ConnectionPool and passing in connectiontype still not using custom Connection class.

  3. Does your application call init_oracle_client()?

yes

This tells us whether you are using the python-oracledb Thin or Thick mode.

thick

  1. Include a runnable Python script that shows the problem.
    
    import oracledb
    oracledb.init_oracle_client()

class Connection(oracledb.Connection): def myfunc(self): print('myfunc')

trying also with custom ConnectionPool

class ConnectionPool(oracledb.ConnectionPool): def init(self, *args, *kwargs): kw = kwargs.copy() kw['connectiontype'] = Connection super().init(args, **kw)

pool = oracledb.create_pool(dsn='test', homogeneous=False, externalauth=False, connectiontype=Connection, pool_class=ConnectionPool) con = pool.acquire(user='dev', password='dev') con.myfunc()


output

Traceback (most recent call last): File "/tmp/pool-test.py", line 18, in con.myfunc() AttributeError: 'Connection' object has no attribute 'myfunc'



When setting externalauth=True then con.myfunc() works.

Same thing using cx_Oracle works.
anthony-tuininga commented 1 week ago

Thanks for reporting the issue. I was able to replicate and correct it. I have initated a build from which you can download pre-built wheels once it completes. You can also build from source if you prefer.

cjbj commented 1 week ago

Note the wheels are from the in-flight development code line - they haven't been through a full regression cycle.

ancc commented 1 day ago

Tested, works!