Skip to content

Commit ff06945

Browse files
Documentation improvements.
1 parent f24399e commit ff06945

File tree

2 files changed

+115
-49
lines changed

2 files changed

+115
-49
lines changed

doc/src/api_manual/module.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ Oracledb Methods
17261726

17271727
.. deprecated:: python-oracledb 1.0
17281728

1729-
Use :ref:`ConnectParams class <connparam>` instead.
1729+
Use the :meth:`oracledb.ConnectParams()` method instead.
17301730

17311731
.. note::
17321732

doc/src/user_guide/appendix_c.rst

Lines changed: 114 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ See :ref:`enablingthick` for more information.
4848
Calling the ``init_oracle_client()`` method immediately loads Oracle Client
4949
libraries. To emulate the cx_Oracle behavior of deferring library loading
5050
until the creation of the first connection (in the case when
51-
``init_oracle_client()`` is not called), your application will need to defer
52-
calling ``init_oracle_client()`` as appropriate.
51+
``init_oracle_client()`` is not called), your application will need to
52+
explicitly defer calling ``init_oracle_client()`` as appropriate.
5353

5454
In python-oracledb, ``init_oracle_client()`` can now be called multiple times
5555
in the one Python process as long as its arguments are the same each time.
@@ -79,11 +79,11 @@ from cx_Oracle:
7979
specification PEP 249. See
8080
:ref:`Standalone Connections <standaloneconnection>` and :ref:`connerrors`.
8181

82-
- New keyword arguments can be passed to :func:`~oracledb.connect()`. For
83-
example you can pass the hostname, port and servicename as separate
82+
- New optional keyword arguments can be passed to :func:`~oracledb.connect()`.
83+
For example you can pass the hostname, port and servicename as separate
8484
parameters instead of using an Easy Connect connection string. In
85-
python-oracledb Thin mode, some of the new arguments replace ``sqlnet.ora``
86-
settings.
85+
python-oracledb Thin mode, some of the new arguments replace :ref:`sqlnet.ora
86+
<optnetfiles>` settings.
8787

8888
- A new optional parameter ``params`` of type :ref:`ConnectParams <connparam>`
8989
can be used to encapsulate connection properties. See :ref:`usingconnparams`
@@ -102,6 +102,11 @@ The use of the class constructor method ``oracledb.Connection()`` to create
102102
connections is no longer recommended for creating connections. Use
103103
:func:`~oracledb.connect()` instead.
104104

105+
The :meth:`oracledb.makedsn()` method for creating the ``dsn`` value has been
106+
deprecated. New code should use :meth:`oracledb.ConnectParams()` or use the
107+
new keyword arguments in :func:`oracledb.connect()`.
108+
109+
105110
Connection Object Differences
106111
+++++++++++++++++++++++++++++
107112

@@ -115,14 +120,19 @@ and cx_Oracle drivers are:
115120
attribute is True if the connection was established in the Thin mode. In
116121
Thick mode, the value of this attribute is False.
117122

123+
- The new method signature of :attr:`Connection.outputtypehandler` is
124+
``handler(cursor, metadata)``. The old signature ``handler(cursor, name,
125+
default_type, length, precision, scale)`` was deprecated in python-oracledb
126+
1.4 but will still work and will be removed in a future version.
127+
118128
See :ref:`connattrs` for more information.
119129

120130
Pooling Differences from cx_Oracle
121131
----------------------------------
122132

123-
It is recommended to use the new equivalent :ref:`ConnectionPool Object
124-
<connpool>` instead of the SessionPool object, which is deprecated. To create
125-
a connection pool, use :meth:`oracledb.create_pool()`, which is equivalent to
133+
It is recommended to use the new :ref:`ConnectionPool Object <connpool>`
134+
instead of the equivalent SessionPool object, which is deprecated. To create a
135+
connection pool, use :meth:`oracledb.create_pool()`, which is equivalent to
126136
calling `cx_Oracle.SessionPool() <https://cx-oracle.readthedocs.io/en/latest/
127137
api_manual/module.html#cx_Oracle.SessionPool>`__.
128138

@@ -144,29 +154,33 @@ SessionPool>`_ as follows:
144154
password is now supported in the same way as :func:`oracledb.connect()`. For
145155
example ``dsn="un/pw@cs"`` can be used.
146156

147-
- New keyword arguments can be passed to :func:`~oracledb.create_pool()`. For
148-
example you can pass the hostname, port and servicename as separate
149-
parameters instead of using an Easy Connect connection string. In
150-
python-oracledb Thin mode, some of the new arguments replace ``sqlnet.ora``
151-
settings.
152-
153-
- The default mode is :data:`~oracledb.POOL_GETMODE_WAIT` instead of
154-
:data:`~oracledb.POOL_GETMODE_NOWAIT`. If the mode
155-
:data:`~oracledb.POOL_GETMODE_NOWAIT` is truly desired, modify any pool
156-
creation code to specify this value instead. Note the namespace of constant
157-
has been improved. Old names like ``SPOOL_ATTRVAL_NOWAIT`` can be used but
158-
are now deprecated.
157+
- New optional keyword arguments can be passed to
158+
:func:`~oracledb.create_pool()`. For example you can pass the hostname, port
159+
and servicename as separate parameters instead of using an Easy Connect
160+
connection string. In python-oracledb Thin mode, some of the new arguments
161+
replace :ref:`sqlnet.ora <optnetfiles>` settings.
159162

160163
- A new optional parameter ``params`` of type :ref:`PoolParams <poolparam>`
161164
can be used to encapsulate connection properties. See :ref:`usingconnparams`
162165
for more information.
163166

164-
- The ``encoding`` and ``decoding`` parameters are deprecated and ignored. The
165-
encodings in use are always UTF-8.
167+
- The default mode is :data:`~oracledb.POOL_GETMODE_WAIT` instead of
168+
:data:`~oracledb.POOL_GETMODE_NOWAIT`. If the mode
169+
:data:`~oracledb.POOL_GETMODE_NOWAIT` is truly desired, modify any pool
170+
creation code to specify this value instead. Note the namespace of
171+
constants has been improved. Old names like ``SPOOL_ATTRVAL_NOWAIT`` can be
172+
used but are now deprecated.
173+
174+
- The ``encoding`` and ``nenecoding`` parameters are deprecated and
175+
ignored. The encodings in use are always UTF-8.
166176

167177
- New keyword arguments that are used internally to create a :ref:`PoolParams
168178
object <connparam>` before creating the connection.
169179

180+
The :meth:`oracledb.makedsn()` method for creating the ``dsn`` value has been
181+
deprecated. New code should use :meth:`oracledb.ConnectParams()` or use the
182+
new keyword arguments to :func:`oracledb.create_pool()`.
183+
170184
SessionPool Object Differences
171185
++++++++++++++++++++++++++++++
172186

@@ -201,31 +215,69 @@ python-oracledb and cx_Oracle drivers are:
201215
:meth:`Cursor.executemany()`, by passing None for the statement argument and
202216
an integer for the parameters argument.
203217

204-
- ``Cursor.bindarraysize``: This attribute is deprecated and removed in
218+
- ``Cursor.bindarraysize``: This attribute is desupported and removed in
205219
python-oracledb. It is not needed in the application code.
206220

207221
- :attr:`Cursor.rowcount`: After :meth:`Cursor.execute()` or
208222
:meth:`Cursor.executemany()` with PL/SQL statements, ``Cursor.rowcount``
209223
will return 0. If the cursor or connection are not open, then the value -1
210224
will be returned as required by the Python Database API.
211225

226+
- :attr:`Cursor.description`: This attribute was previously a sequence of
227+
7-item sequences in cx_Oracle and python-oracledb. Each of these sequences
228+
contained information describing one result column, that is, (name, type,
229+
display_size, internal_size, precision, scale, null_ok). In
230+
python-oracledb 1.4, this attribute was changed to a sequence of
231+
:ref:`FetchInfo <fetchinfoobj>` objects. Each FetchInfo object describes one
232+
result column and can behave as a 7-tuple like before, but contains
233+
additional information that may be helpful when using
234+
:ref:`output type handlers <outputtypehandlers>`.
235+
236+
- :attr:`Cursor.outputtypehandler`: The new method signature of this attribute
237+
is ``handler(cursor, metadata)``. The old signature ``handler(cursor, name,
238+
default_type, length, precision, scale)`` was deprecated in python-oracledb
239+
1.4 but will still work and will be removed in a future version.
240+
241+
.. _fetchisjson:
242+
243+
Fetching IS JSON Column Differences from cx_Oracle
244+
--------------------------------------------------
245+
246+
In python-oracledb, VARCHAR2 and LOB columns that have the ``IS JSON``
247+
constraint enabled are fetched as Python objects. These columns are fetched in
248+
the same way that :ref:`JSON type columns <json21fetch>` are fetched when
249+
using Oracle Database 21c (or later). The returned value varies depending on
250+
the JSON data. If the JSON data is an object, then a dictionary is returned.
251+
If it is an array, then a list is returned. If it is a scalar value, then that
252+
particular scalar value is returned.
253+
254+
In cx_Oracle, VARCHAR2 and LOB columns that have the ``IS JSON`` constraint
255+
enabled are fetched as strings and LOB objects respectively. To enable this
256+
same fetch behavior in python-oracledb, you must use an
257+
:ref:`output type handler <outputtypehandlers>` as shown below.
258+
259+
.. code-block:: python
260+
261+
def type_handler(cursor, fetch_info):
262+
if fetch_info.is_json:
263+
return cursor.var(fetch_info.type_code, cursor.arraysize)
264+
212265
Advanced Queuing (AQ) Differences from cx_Oracle
213266
------------------------------------------------
214267

215-
The old Advanced Queuing (AQ) API is not available in python-oracledb since it
216-
was deprecated in cx_Oracle 7.2. Use the
217-
:ref:`new Advanced Queuing (AQ) <aqusermanual>`. Note that AQ is only
218-
available in the Thick mode.
268+
Use the new :ref:`Advanced Queuing (AQ) <aqusermanual>` API instead of the
269+
older API which was deprecated in cx_Oracle 7.2 and is not available in
270+
python-oracledb. Note that AQ is only available in python-oracledb Thick mode.
219271

220272
Replace:
221273

222-
- :meth:`Connection.deq()` with :meth:`Queue.deqone()` or :meth:`Queue.deqmany()`
223-
- :meth:`Connection.deqoptions()` with attribute :attr:`Queue.deqoptions`
224-
- :meth:`Connection.enq()` with :meth:`Queue.enqone()` or :meth:`Queue.enqmany()`
225-
- :meth:`Connection.deqoptions()` with attribute :attr:`Queue.deqoptions`
274+
- ``Connection.deq()`` with :meth:`Queue.deqone()` or :meth:`Queue.deqmany()`
275+
- ``Connection.deqoptions()`` with attribute :attr:`Queue.deqoptions`
276+
- ``Connection.enq()`` with :meth:`Queue.enqone()` or :meth:`Queue.enqmany()`
277+
- ``Connection.enqoptions()`` with attribute :attr:`Queue.enqoptions`
226278

227-
The AQ feature in the python-oracledb driver differs from cx_Oracle as
228-
follows:
279+
The AQ support in python-oracledb has the following enhancements from
280+
cx_Oracle:
229281

230282
- AQ messages can be enqueued and dequeued as a JSON payload type
231283
- Recipient lists can be enqueued and dequeued
@@ -241,10 +293,10 @@ Error Handling Differences from cx_Oracle
241293
In python-oracledb Thick mode, error messages generated by the Oracle Client
242294
libraries and the `ODPI-C <https://oracle.github.io/odpi/>`_ layer used by
243295
cx_Oracle and python-oracledb in Thick mode are mostly returned unchanged from
244-
cx_Oracle 8.3 with the exceptions shown below.
296+
cx_Oracle 8.3. Some exceptions shown below.
245297

246-
Note that the python-oracledb driver error messages can vary between Thin and
247-
Thick modes. See :ref:`errorhandling`.
298+
Note that the python-oracledb driver error messages can also vary between Thin
299+
and Thick modes. See :ref:`errorhandling`.
248300

249301
ConnectionPool.acquire() Message Differences
250302
++++++++++++++++++++++++++++++++++++++++++++
@@ -379,19 +431,20 @@ to python-oracledb:
379431
containing the file, or set :attr:`defaults.config_dir`, or set the
380432
``config_dir`` parameter when connecting.
381433

382-
Only python-oracledb Thick mode will read ``sqlnet.ora`` files. The Thin
383-
mode lets equivalent properties be set in the application when connecting.
434+
Only python-oracledb Thick mode will read :ref:`sqlnet.ora <optnetfiles>`
435+
files. The Thin mode lets equivalent properties be set in the application
436+
when connecting.
384437

385438
Configuration files in a "default" location such as the Instant Client
386439
``network/admin/`` subdirectory, in ``$ORACLE_HOME/network/admin/``, or in
387440
``$ORACLE_BASE/homes/XYZ/network/admin/`` (in a read-only Oracle Database
388-
home) is not automatically loaded in Thin mode. Default locations are
389-
automatically searched by Thick mode.
441+
home) are not automatically loaded in Thin mode. Default locations are
442+
only automatically searched in Thick mode.
390443

391444
- To use the python-oracledb Thin mode in an ORACLE_HOME database installation
392-
environment, you use an explicit connection string since the ``ORACLE_SID``,
393-
``TWO_TASK`` and ``LOCAL`` environment variables are not used. They are
394-
used in Thick mode.
445+
environment, you must use an explicit connection string since the
446+
``ORACLE_SID``, ``TWO_TASK``, and ``LOCAL`` environment variables are not
447+
used. They are used in Thick mode.
395448

396449
- This is a major release so some previously deprecated features are no longer
397450
available. See :ref:`deprecations`.
@@ -504,7 +557,20 @@ following steps:
504557
as :data:`~oracledb.POOL_GETMODE_NOWAIT` and :data:`~oracledb.PURITY_SELF`
505558
are now preferred. The old namespaces still work.
506559

507-
7. Review the following sections to see if your application requirements are
560+
7. The method signature of the :ref:`output type handler <outputtypehandlers>`
561+
which can be specified on a
562+
:attr:`connection <Connection.outputtypehandler>` or on a
563+
:attr:`cursor <Cursor.outputtypehandler>` is ``handler(cursor, metadata)``.
564+
The old signature ``handler(cursor, name, default_type, length, precision,
565+
scale)`` was deprecated in python-oracledb 1.4 but will still work and will
566+
be removed in a future version.
567+
568+
8. VARCHAR2 and LOB columns that have the ``IS JSON`` constraint enabled are
569+
fetched by default as Python objects in python-oracledb. In cx_Oracle,
570+
VARCHAR2 and LOB columns that contain JSON data are fetched by default as
571+
strings and LOB objects respectively. See :ref:`fetchisjson`.
572+
573+
9. Review the following sections to see if your application requirements are
508574
satisfied by the python-oracledb Thin mode:
509575

510576
- :ref:`featuresummary`
@@ -513,14 +579,14 @@ following steps:
513579
If your application requirements are not supported by the Thin mode, then
514580
use the python-oracledb Thick mode.
515581

516-
8. Review :ref:`compatibility`.
582+
10. Review :ref:`compatibility`.
517583

518584
If your code base uses an older cx_Oracle version, review the previous
519585
:ref:`release notes <releasenotes>` for additional changes to modernize
520586
the code.
521587

522-
9. Modernize code as needed or desired. See :ref:`deprecations` for the list
523-
of deprecations in python-oracledb.
588+
11. Modernize code as needed or desired. See :ref:`deprecations` for the list
589+
of deprecations in python-oracledb.
524590

525591
Additional Upgrade Steps to use python-oracledb Thin Mode
526592
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

0 commit comments

Comments
 (0)