Skip to content

Commit 28d20b2

Browse files
Documentation improvements.
1 parent 51bf65f commit 28d20b2

File tree

10 files changed

+112
-69
lines changed

10 files changed

+112
-69
lines changed

doc/src/api_manual/connect_param.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ ConnectParams Attributes
9898
`tracing <https://www.oracle.com/pls/topic/lookup?
9999
ctx=dblatest&id=GUID-B0FC69F9-2EBC-44E8-ACB2-62FBA14ABD5C>`__.
100100

101+
.. versionadded:: 1.4.0
102+
101103
.. attribute:: ConnectParams.debug_jdwp
102104

103105
This read-only attribute is a string with the format

doc/src/api_manual/connection.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ Connection Attributes
689689
associated with the connection. It is the same value as the SQL expression
690690
``sys_context('userenv', 'instance_name')``.
691691

692+
.. versionadded:: 1.4.0
693+
692694
.. note::
693695

694696
This attribute is an extension to the DB API definition.

doc/src/api_manual/cursor.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Cursor Methods
442442
meaning that python-oracledb does not do any decoding. See :ref:`Fetching raw
443443
data <fetching-raw-data>` for more information.
444444

445-
The ``convert_nulls`` parameter, if specified, should be passed a boolean
445+
The ``convert_nulls`` parameter, if specified, should be passed as a boolean
446446
value. Passing the value ``True`` causes the ``outconverter`` to be called
447447
when a null value is fetched from the database; otherwise, the
448448
``outconverter`` is only called when non-null values are fetched from the
@@ -452,7 +452,7 @@ Cursor Methods
452452
parameter `encodingErrors` was renamed to `encoding_errors`. The old
453453
name will continue to work as a keyword parameter for a period of time.
454454

455-
.. versionchanged:: 1.4
455+
.. versionchanged:: 1.4.0
456456

457457
The ``convert_nulls`` parameter was added.
458458

@@ -511,6 +511,12 @@ Cursor Attributes
511511
or if the cursor has not had an operation invoked via the
512512
:meth:`~Cursor.execute()` method yet.
513513

514+
.. versionchanged:: 1.4.0
515+
516+
Previously, this attribute was a sequence of 7-item sequences. Each
517+
of these sequences contained information describing one result column:
518+
(name, type, display_size, internal_size, precision, scale, null_ok).
519+
514520
.. attribute:: Cursor.fetchvars
515521

516522
This read-only attribute specifies the list of variables created for the
@@ -554,7 +560,7 @@ Cursor Attributes
554560

555561
See :ref:`outputtypehandlers`.
556562

557-
.. versionchanged:: 1.4
563+
.. versionchanged:: 1.4.0
558564

559565
The method signature was changed. The previous signature
560566
handler(cursor, name, default_type, length, precision, scale) will

doc/src/api_manual/fetch_info.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ attributes ``name``, ``type_code``, ``display_size``, ``internal_size``,
1212
``fetch_info`` is of type FetchInfo, then ``fetch_info[2]`` is the same as
1313
``fetch_info.display_size``.
1414

15+
.. versionadded:: 1.4.0
16+
1517
.. note::
1618

1719
This object is an extension the DB API.

doc/src/api_manual/module.rst

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ API: python-oracledb Module
1111
Oracledb Methods
1212
================
1313

14-
.. data:: __future__
15-
16-
Special object which contains attributes which control the behavior of
17-
python-oracledb, allowing for opting in for new features. No attributes are
18-
currently supported so all attributes will silently ignore being set and
19-
will always appear to have the value None.
20-
21-
.. note::
22-
23-
This method is an extension to the DB API definition.
24-
25-
2614
.. function:: Binary(string)
2715

2816
Constructs an object holding a binary (long) string value.
@@ -1291,6 +1279,30 @@ Oracledb Methods
12911279
(number of seconds since the epoch; see the documentation of the standard
12921280
Python time module for details).
12931281

1282+
.. _futureobj:
1283+
1284+
Oracledb.__future__ Object
1285+
==========================
1286+
1287+
Special object that contains attributes which control the behavior of
1288+
python-oracledb, allowing for opting in for new features.
1289+
1290+
.. note::
1291+
1292+
This method is an extension to the DB API definition.
1293+
1294+
.. attribute:: __future__.old_json_col_as_obj
1295+
1296+
A boolean attribute which when set to *True* while using Oracle Database
1297+
12c (or later), fetches VARCHAR2 and LOB columns that were created with
1298+
the ``IS JSON`` constraint and therefore contain JSON data in the same way
1299+
that :ref:`columns of type JSON <json21fetch>` are fetched when using
1300+
Oracle Database 21c (or later).
1301+
1302+
In python-oracledb 2.0, the setting of this attribute will no longer be
1303+
required since this will be the default behavior.
1304+
1305+
.. versionadded:: 1.4.0
12941306

12951307
.. _constants:
12961308

doc/src/api_manual/soda.rst

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -541,30 +541,6 @@ SodaOperation Methods
541541
Use of this method requires Oracle Client 21.3 or higher (or Oracle Client
542542
19 from 19.11).
543543

544-
545-
.. method:: SodaOperation.lock()
546-
547-
Specifies whether the documents fetched from the collection should be
548-
locked (equivalent to SQL "select for update").
549-
550-
The next commit or rollback on the connection made after the operation is
551-
performed will "unlock" the documents. Ensure that the connection is not in
552-
autocommit mode or the documents will be unlocked immediately after the
553-
operation is complete.
554-
555-
This method should only be used with read operations (other than
556-
:func:`~SodaOperation.count()`) and should not be used in
557-
conjunction with non-terminal methods :meth:`~SodaOperation.skip()` and
558-
:meth:`~SodaOperation.limit()`.
559-
560-
If this method is specified in conjunction with a write operation this
561-
method is ignored.
562-
563-
This method is only supported in Oracle Client 21.3 and higher (also
564-
available in Oracle Client 19 from 19.11).
565-
566-
.. versionadded:: 1.4
567-
568544
.. method:: SodaOperation.key(value)
569545

570546
Specifies that the document with the specified key should be returned.
@@ -597,6 +573,29 @@ SodaOperation Methods
597573
criteria can be specified by chaining methods together.
598574

599575

576+
.. method:: SodaOperation.lock()
577+
578+
Specifies whether the documents fetched from the collection should be
579+
locked (equivalent to SQL "select for update").
580+
581+
The next commit or rollback on the connection made after the operation is
582+
performed will "unlock" the documents. Ensure that the connection is not in
583+
autocommit mode or the documents will be unlocked immediately after the
584+
operation is complete.
585+
586+
This method should only be used with read operations (other than
587+
:func:`~SodaOperation.count()`) and should not be used in
588+
conjunction with non-terminal methods :meth:`~SodaOperation.skip()` and
589+
:meth:`~SodaOperation.limit()`.
590+
591+
If this method is specified in conjunction with a write operation this
592+
method is ignored.
593+
594+
This method is only supported in Oracle Client 21.3 or later (or
595+
Oracle Client 19 from 19.11).
596+
597+
.. versionadded:: 1.4.0
598+
600599
.. method:: SodaOperation.remove()
601600

602601
Removes all of the documents in the collection that match the criteria. The

doc/src/api_manual/subscription.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ Message Objects
136136

137137
This read-only attribute returns a list of message query objects that give
138138
information about query result sets changed for this notification. This
139-
attribute will be None if the ``qos`` parameter did not include the flag
140-
:data:`~oracledb.SUBSCR_QOS_QUERY` when the subscription was created.
139+
attribute will be an empty list if the ``qos`` parameter did not include
140+
the flag :data:`~oracledb.SUBSCR_QOS_QUERY` when the subscription was
141+
created.
141142

142143

143144
.. attribute:: Message.queue_name
@@ -170,7 +171,7 @@ Message Objects
170171

171172
This read-only attribute returns a list of message table objects that give
172173
information about the tables changed for this notification. This
173-
attribute will be None if the ``qos`` parameter included the flag
174+
attribute will be an empty list if the ``qos`` parameter included the flag
174175
:data:`~oracledb.SUBSCR_QOS_QUERY` when the subscription was created.
175176

176177

doc/src/api_manual/variable.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ Variable Attributes
5252

5353
.. attribute:: Variable.convert_nulls
5454

55-
This read-only attribute returns whether the :data:`~Variable.outconverter`
55+
This read-only attribute returns whether the :attr:`~Variable.outconverter`
5656
method is called when null values are fetched from the database.
5757

58-
.. versionadded:: 1.4
58+
.. versionadded:: 1.4.0
5959

6060
.. attribute:: Variable.inconverter
6161

doc/src/release_notes.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,35 @@ Thin Mode Changes
1717
performance of connection creation by reducing the number of round trips
1818
required to create the second and subsequent connections to the same
1919
database.
20-
#) Added support for the ``ORA_SDTZ`` environment variable used to set the
21-
session time zone used by the database.
22-
#) Added support for shrinking the pool back to the minimum number of
23-
connections allowed in the pool when the pool is idle for
24-
:data:`ConnectionPool.timeout` seconds.
25-
#) Added support for sending a generated connection identifier to the
26-
database used for tracing. An application specific prefix is prepended to
27-
this value if specified via a new ``connection_id_prefix`` parameter when
28-
creating standalone connections or connection pools.
29-
#) Added support for growing the pool back to the minimum number of
30-
connections allowed in the pool when connections are killed or otherwise
31-
made unusable.
32-
#) Added URL to the Oracle Database Error Help Portal in Oracle Database
33-
error messages similar to when Thick mode uses Oracle Client 23c.
20+
#) Added support for shrinking the connection pool back to the specified
21+
minimum size when the pool is idle for :data:`ConnectionPool.timeout`
22+
seconds.
23+
#) Added support for growing the connection pool back to the minimum number of
24+
connections after connections are killed or otherwise made unusable.
3425
#) A default connection class is now generated when DRCP is used with a
3526
connection pool and no connection class was specified when the pool was
3627
created. The default connection class will be of the form ``DPY:`` followed
3728
by a 16-byte unique identifier converted to base64 encoding.
3829
#) Changed internal connection feature negotiation for more accurate Oracle
3930
Database 23c support.
40-
#) Fixed bug when a dynamically sized pool is created with an ``increment``
41-
of zero and the pool needs to grow.
31+
#) Added support for sending a generated connection identifier to the
32+
database used for tracing. An application specific prefix is prepended to
33+
this value if specified via a new ``connection_id_prefix`` parameter when
34+
creating standalone connections or connection pools.
35+
#) Added URL to the Oracle Database Error Help Portal in Oracle Database
36+
error messages similar to when Thick mode uses Oracle Client 23c.
37+
#) Added support for the ``ORA_SDTZ`` environment variable used to set the
38+
session time zone used by the database.
39+
#) Fixed bug when a dynamically sized connection pool is created with an
40+
``increment`` of zero and the pool needs to grow.
4241
#) Fixed bug affecting connection reuse when connections were acquired from
4342
the connection pool with a ``cclass`` different to the one used to
4443
create the pool.
45-
#) Fixed bug when a connection is discarded from the pool during
44+
#) Fixed bug when a connection is discarded from the connection pool during
4645
:meth:`ConnectionPool.acquire()` and the ping check fails due to the
4746
connection being dead.
4847
#) Fixed bug when an output type handler is used and the value of
49-
cursor.prefetchrows exceeds cursor.arraysize
48+
:attr:`Cursor.prefetchrows` exceeds :attr:`Cursor.arraysize`
5049
(`issue 173 <https://github.com/oracle/python-oracledb/issues/173>`__).
5150
#) Fixed bug when an Application Continuity replay context is returned during
5251
connection to the database
@@ -58,7 +57,7 @@ Thin Mode Changes
5857
Thick Mode Changes
5958
++++++++++++++++++
6059

61-
#) Added function :meth:`SodaCollection.getIndexes()` for getting the indexes
60+
#) Added function :meth:`SodaCollection.listIndexes()` for getting the indexes
6261
on a SODA collection.
6362
#) Added support for specifying if documents should be locked when fetched
6463
from SODA collections. A new non-terminal method
@@ -87,12 +86,12 @@ Common Changes
8786
``handler(cursor, metadata)`` where the ``metadata`` parameter is a
8887
:ref:`FetchInfo<fetchinfoobj>` object containing the same information found
8988
in :data:`Cursor.description`. The original signature for output type
90-
handlers is deprecated and will be removed in some future version.
89+
handlers is deprecated and will be removed in a future version.
9190
#) Added support for fetching VARCHAR2 and LOB columns which contain JSON (and
9291
have the "IS JSON" check constraint enabled) in the same way as columns of
9392
type JSON (which requires Oracle Database 21c or higher) are fetched. In
9493
thick mode this requires Oracle Client 19c or higher. The attribute
95-
``oracledb.__future__.old_json_col_as_obj`` must be set to the value
94+
:attr:`oracledb.__future__.old_json_col_as_obj` must be set to the value
9695
``True`` for this behavior to occur. In version 2.0 this will become the
9796
normal behavior and setting this attribute will no longer be needed.
9897
#) Added new property :attr:`Connection.instance_name` which provides the
@@ -163,7 +162,8 @@ Thin Mode Changes
163162
#) Fixed bug with Oracle Database 23c when SQL is executed after first being
164163
parsed.
165164
#) Fixed bug when :data:`ConnectionPool.timeout` is not `None` when creating a
166-
pool (`issue 166 <https://github.com/oracle/python-oracledb/issues/166>`__).
165+
connection pool
166+
(`issue 166 <https://github.com/oracle/python-oracledb/issues/166>`__).
167167
#) Fixed bug when a query is re-executed after an underlying table is dropped
168168
and recreated, and the query select list contains LOBs or JSON data.
169169
#) Fixed bug when warning message such as for impending password expiry is

doc/src/user_guide/json_data_type.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ binding as shown below:
7575
cursor.setinputsizes(None, oracledb.DB_TYPE_JSON)
7676
cursor.execute(insert_sql, [1, data])
7777
78+
.. _json21fetch:
79+
7880
To fetch a JSON column, use:
7981

8082
.. code-block:: python
@@ -83,7 +85,7 @@ To fetch a JSON column, use:
8385
print(row)
8486
8587
See `json_direct.py
86-
<https://github.com/oracle/python-oracledb/tree/main/samplesjson_direct.py>`__
88+
<https://github.com/oracle/python-oracledb/tree/main/samples/json_direct.py>`__
8789
for a runnable example. The example also shows how to use this type when
8890
python-oracledb Thick mode uses older Oracle Client libraries.
8991

@@ -102,7 +104,24 @@ insert JSON strings like:
102104
103105
cursor.execute(inssql, [1, json.dumps(data)])
104106
105-
To fetch JSON strings, use:
107+
You can fetch VARCHAR2 and LOB columns that contain JSON data without needing
108+
to call ``json.loads()`` on the value (similar to
109+
:ref:`fetching JSON type columns <json21fetch>` when using Oracle Database
110+
21c). This can be done by setting the attribute
111+
:attr:`oracledb.__future__.old_json_col_as_obj` to the value *True* as shown
112+
below. If you are using python-oracledb Thick mode, you must also use Oracle
113+
Client 19c (or later).
114+
115+
.. code-block:: python
116+
117+
oracledb.__future__.old_json_col_as_obj = True
118+
119+
for row in cursor.execute("select * from CustomersAsBlob"):
120+
print(row)
121+
122+
To fetch JSON without setting the attribute
123+
``oracledb.__future__.old_json_col_as_obj``, you can use ``json.loads()`` on
124+
the returned data. For example, to fetch JSON which uses BLOB storage:
106125

107126
.. code-block:: python
108127
@@ -113,7 +132,7 @@ To fetch JSON strings, use:
113132
print(json.loads(j.read()))
114133
115134
See `json_blob.py
116-
<https://github.com/oracle/python-oracledb/tree/main/samplesjson_blob.py>`__
135+
<https://github.com/oracle/python-oracledb/tree/main/samples/json_blob.py>`__
117136
for a runnable example.
118137

119138
IN Bind Type Mapping

0 commit comments

Comments
 (0)