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

`LOB.getchunksize()` not supported in thin mode

Open doerwalter opened this issue 3 years ago • 1 comments

The following Python script

import oracledb

db = oracledb.connect("user/pwd@db", config_dir=os.environ["ORACLE_HOME"] + "/network/admin")
lob = db.cursor().execute("select to_clob('foo') from dual").fetchone()[0]
lob.getchunksize()

gives the following stacktrace:

Traceback (most recent call last):
  File "/Users/walter/oracledb_bug.py", line 6, in <module>
    lob.getchunksize()
  File "/Users/walter/pyvenvs/default/lib/python3.10/site-packages/oracledb/lob.py", line 75, in getchunksize
    return self._impl.get_chunk_size()
  File "/Users/walter/pyvenvs/default/lib/python3.10/site-packages/oracledb/utils.py", line 51, in wrapped_f
    errors._raise_err(errors.ERR_FEATURE_NOT_SUPPORTED,
  File "/Users/walter/pyvenvs/default/lib/python3.10/site-packages/oracledb/errors.py", line 103, in _raise_err
    raise exc_type(_Error(message)) from cause
oracledb.exceptions.NotSupportedError: DPY-3001: getting the chunk size of a LOB is only supported in python-oracledb thick mode

The documentation for getchunksize() states:

Returns the chunk size for the internal LOB. Reading and writing to the LOB in chunks of multiples of this size will improve performance.

Is there even something like an "optmal chunk size" in thin mode? If this isn't relevant for thin mode the documentation (and/or the exception message?) should suggest which chunk size should be used for reading a LOB.

doerwalter avatar Jun 08 '22 18:06 doerwalter

@doerwalter, I've added a patch that adds the necessary support to the thin driver. If you are able to build the driver yourself you can make use of it and provide any feedback you might have; otherwise, it will be included in 1.1 when that version is released.

anthony-tuininga avatar Jul 19 '22 22:07 anthony-tuininga

This enhancement has been implemented in python-oracledb 1.1.0 which was just released.

anthony-tuininga avatar Sep 14 '22 16:09 anthony-tuininga