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

correct connectiontype not returned after acquring a connection from a pool

Open cameronclaero opened this issue 2 years ago • 2 comments

  1. What versions are you using? 2.0.1

import sys import platform rm:", platform.platform()) print("sys.maxsize > 2*>>> print("platform.platform:", platform.platform()) *32:", sys.maxsize > 232) print("platform.pythonplatform.platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.31 print("sys.maxsize > 232:", sys.maxsize > 232) sys.maxsize > 232: True print("platform.python_version:", platform.python_version()) platform.python_version: 3.9.2

import oracledb print("oracledb.version:", oracledb.version) oracledb.version: 2.0.1

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

  2. What error(s) or behavior you are seeing?

wrong connection type returned from acquire, after setting connectiontype as part of the create_pool call.

Note that this same code used to work in cx_oracle. (create_session)

  1. Does your application call init_oracle_client()?

yes

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

_CLAEROPool = None 
oracledb.init_oracle_client()
oracledb.defaults.fetch_lobs = False


class TestConnection(oracledb.Connection):
    pass


_CLAEROPool = oracledb.create_pool(min=1,
                                   max=3, 
                                   increment=1, 
                                   dsn="whatever",
                                   connectiontype=TestConnection)

with _CLAEROPool.acquire() as conn:
    print(type(conn))

cameronclaero avatar Jan 29 '24 00:01 cameronclaero

I just tried a slight variation of your code. It worked just fine:

import oracledb

oracledb.init_oracle_client()

class TestConnection(oracledb.Connection):
    pass

pool = oracledb.create_pool(min=1, max=3, increment=1,
                            dsn="localhost:1521/DB21PDB1",
                            user="python", password="dev",
                            connectiontype=TestConnection)

with pool.acquire() as conn:
    print(type(conn))

The result I get is:

<class '__main__.TestConnection'>

which is exactly what I would expect. What are you getting?

anthony-tuininga avatar Feb 01 '24 21:02 anthony-tuininga

It was returning a oracledb.Connection in my tests, of which it would return the right one when using cx_oracle, so I had to go back to using cx_oracle. this was in a container with v23 drivers installed, so I'd have to re-set up my environment to re-test. Will send some info through once I can confirm. Thanks for taking a look anyway

cameronclaero avatar Feb 01 '24 22:02 cameronclaero

@cameronclaero is there any update on this, or can it be closed?

cjbj avatar Apr 10 '24 14:04 cjbj

Closing - no activity

anthony-tuininga avatar May 09 '24 22:05 anthony-tuininga