Skip to content

Commit 50b32ac

Browse files
Documentation improvements.
1 parent 2475d9b commit 50b32ac

File tree

14 files changed

+1387
-1134
lines changed

14 files changed

+1387
-1134
lines changed

doc/src/api_manual/defaults.rst

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,107 +11,80 @@ Defaults Class
1111

1212
.. autoclass:: Defaults
1313

14-
A Defaults object contains attributes that can be used to adjust the
15-
behavior of the python-oracledb driver.
14+
See :ref:`settingdefaults`.
1615

17-
An example of changing a default value is:
18-
19-
.. code-block:: python
20-
21-
import oracledb
22-
23-
oracledb.defaults.fetch_lobs = False # return LOBs directly as strings or bytes
16+
.. _defaultsattributes:
2417

2518
Defaults Attributes
2619
===================
2720

2821
.. autoproperty:: Defaults.arraysize
2922

30-
This is an attribute for tuning the performance of fetching rows from
31-
Oracle Database. It does not affect data insertion. See :ref:`Tuning Fetch
32-
Performance <tuningfetch>`.
23+
See :ref:`Tuning Fetch Performance <tuningfetch>`.
3324

3425
.. autoproperty:: Defaults.config_dir
3526

36-
At time of ``import oracledb`` the value of
37-
``oracledb.defaults.config_dir`` will be set to (first one wins):
38-
39-
- the value of ``$TNS_ADMIN``, if ``TNS_ADMIN`` is set.
40-
41-
- ``$ORACLE_HOME/network/admin``, if ``$ORACLE_HOME`` is set.
42-
43-
Otherwise, ``oracledb.defaults.config_dir`` will not be set.
44-
4527
See :ref:`optnetfiles`.
4628

4729
.. versionchanged:: 3.0.0
4830

4931
The directory ``$ORACLE_HOME/network/admin`` was added to the
5032
heuristic.
5133

52-
At completion of a call to :meth:`oracledb.init_oracle_client()` in
53-
Thick mode, the value of :attr:`Defaults.config_dir` may get changed
54-
by python-oracledb.
55-
5634
.. autoproperty:: Defaults.driver_name
5735

58-
See :ref:`otherinit`.
36+
See :ref:`otherinit` and :ref:`dbviews`.
5937

6038
.. versionadded:: 2.5.0
6139

6240
.. autoproperty:: Defaults.fetch_decimals
6341

64-
An output type handler such as previously required in the obsolete
65-
cx_Oracle driver can alternatively be used to adjust the returned type. If
66-
a type handler exists and returns a variable (that is,
67-
``cursor.var(...)``), then that return variable is used. If the type
68-
handler returns *None*, then the value of
69-
``oracledb.defaults.fetch_decimals`` is used to determine whether to return
70-
``decimal.Decimal`` values.
42+
See `decimal.Decimal <https://docs.python.org
43+
/3/library/decimal.html#decimal-objects>`__.
7144

7245
.. autoproperty:: Defaults.fetch_lobs
7346

7447
See :ref:`lobdata`.
7548

76-
An output type handler such as the one previously required in the obsolete
77-
cx_Oracle driver can alternatively be used to adjust the returned type. If
78-
a type handler exists and returns a variable (that is, `cursor.var(...)`),
79-
then that return variable is used. If the type handler returns *None*, then
80-
the value of ``oracledb.defaults.fetch_lobs`` is used.
81-
8249
.. autoproperty:: Defaults.machine
8350

51+
See :ref:`dbviews`.
52+
8453
.. versionadded:: 2.5.0
8554

8655
.. autoproperty:: Defaults.osuser
8756

57+
See :ref:`dbviews`.
58+
8859
.. versionadded:: 2.5.0
8960

9061
.. autoproperty:: Defaults.prefetchrows
9162

92-
This is an attribute for tuning the performance of fetching rows from
93-
Oracle Database. It does not affect data insertion. See :ref:`Tuning Fetch
94-
Performance <tuningfetch>`.
63+
See :ref:`tuningfetch`.
9564

9665
.. autoproperty:: Defaults.program
9766

67+
See :ref:`dbviews`.
68+
9869
.. versionadded:: 2.5.0
9970

10071
.. autoproperty:: Defaults.stmtcachesize
10172

102-
This is a tuning attribute, see :ref:`stmtcache`.
73+
See :ref:`stmtcache`.
10374

10475
.. autoproperty:: Defaults.terminal
10576

77+
See :ref:`dbviews`.
78+
10679
.. versionadded:: 2.5.0
10780

10881
.. autoproperty:: Defaults.thick_mode_dsn_passthrough
10982

11083
When ``thick_mode_dsn_passthrough`` is the default value `True`, the
111-
behavior of python-oracledb 2.5 and earlier versions occurs: Thick mode
112-
passes connect strings unchanged to the Oracle Client libraries to
113-
handle. Those libraries have their own heuristics for locating the optional
114-
:ref:`tnsnames.ora <optnetfiles>`, if used.
84+
behavior of python-oracledb 2.5 and earlier versions occurs:
85+
python-oracledb Thick mode passes connect strings unchanged to the Oracle
86+
Client libraries to handle. Those libraries have their own heuristics for
87+
locating the optional :ref:`tnsnames.ora <optnetfiles>`, if used.
11588

11689
When ``thick_mode_dsn_passthrough`` is `False`, python-oracledb Thick mode
11790
behaves similarly to Thin mode, which can be helpful for applications that

doc/src/api_manual/module.rst

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -267,77 +267,51 @@ Oracledb Methods
267267
.. versionadded:: 3.0.0
268268

269269

270-
.. _interval_ym:
271-
272-
Oracledb IntervalYM Class
273-
=========================
270+
.. _moduleattributes:
274271

275-
Objects of this class are returned for columns of type INTERVAL YEAR TO MONTH
276-
and can be passed to variables of type :data:`oracledb.DB_TYPE_INTERVAL_YM`
277-
The class is a `collections.namedtuple()
278-
<https://docs.python.org/3/library/collections.html#collections.namedtuple>`__
279-
class with two integer attributes, ``years`` and ``months``.
280-
281-
.. versionadded:: 2.2.0
282-
283-
284-
.. _jsonid:
285-
286-
Oracledb JsonId Class
287-
=====================
288-
289-
Objects of this class are returned by :ref:`SODA <soda>` in the ``_id``
290-
attribute of documents stored in native collections when using Oracle Database
291-
23.4 (and later). It is a subclass of the `bytes <https://docs.python.org/3/
292-
library/stdtypes.html#bytes>`__ class.
293-
294-
.. versionadded:: 2.1.0
295-
296-
297-
.. _futureobj:
298-
299-
Oracledb __future__ Object
300-
==========================
301-
302-
Special object that contains attributes which control the behavior of
303-
python-oracledb, allowing for opting in for new features.
304-
305-
.. dbapimethodextension::
306-
307-
.. _constants:
272+
Oracledb Attributes
273+
===================
308274

309-
Oracledb Constants
310-
==================
275+
.. data:: apilevel
311276

312-
General
313-
-------
277+
A string constant stating the Python DB API level supported by
278+
python-oracledb. Currently "2.0".
314279

315-
.. data:: apilevel
280+
.. data:: defaults
316281

317-
String constant stating the supported DB API level. Currently '2.0'.
282+
The :ref:`Defaults <defaults>` object for setting default behaviors of
283+
python-oracledb.
318284

285+
See :ref:`settingdefaults`.
319286

320287
.. data:: paramstyle
321288

322-
String constant stating the type of parameter marker formatting expected by
323-
the interface. Currently 'named' as in 'where name = :name'.
289+
A string constant stating the type of parameter marker formatting expected
290+
by the interface. Currently 'named' as in 'where name = :name'.
324291

325292

326293
.. data:: threadsafety
327294

328-
Integer constant stating the level of thread safety that the interface
329-
supports. Currently 2, which means that threads may share the module and
295+
An integer constant stating the level of thread safety that python-oracledb
296+
supports. Currently 2, which means that threads may share the module and
330297
connections, but not cursors. Sharing means that a thread may use a
331298
resource without wrapping it using a mutex semaphore to implement resource
332299
locking.
333300

334301
.. data:: version
302+
303+
A string constant stating the version of the module. Currently '|release|'.
304+
335305
.. data:: __version__
336306

337-
String constant stating the version of the module. Currently '|release|'.
307+
A string constant stating the version of the module. Currently '|release|'.
338308

339309
.. dbapiattributeextension::
340310

311+
.. _constants:
312+
313+
Oracledb Constants
314+
==================
341315

342316
Advanced Queuing: Delivery Modes
343317
--------------------------------
@@ -1869,6 +1843,14 @@ See :ref:`exception` for usage information.
18691843

18701844
See :ref:`tg` for more information.
18711845

1846+
.. _futureobj:
1847+
1848+
Oracledb __future__ Object
1849+
==========================
1850+
1851+
A special object that contains attributes which control the behavior of
1852+
python-oracledb, allowing for opting in for new features.
1853+
18721854
.. _oracledbplugins:
18731855

18741856
Oracledb Plugins
@@ -1979,3 +1961,30 @@ Python-oracledb then uses these tokens to connect to Oracle Database.
19791961
See :ref:`cloudnativeauthoauth` for more information.
19801962

19811963
.. versionadded:: 3.0.0
1964+
1965+
.. _interval_ym:
1966+
1967+
Oracledb IntervalYM Class
1968+
=========================
1969+
1970+
Objects of this class are returned for columns of type INTERVAL YEAR TO MONTH
1971+
and can be passed to variables of type :data:`oracledb.DB_TYPE_INTERVAL_YM`
1972+
The class is a `collections.namedtuple()
1973+
<https://docs.python.org/3/library/collections.html#collections.namedtuple>`__
1974+
class with two integer attributes, ``years`` and ``months``.
1975+
1976+
.. versionadded:: 2.2.0
1977+
1978+
.. _jsonid:
1979+
1980+
Oracledb JsonId Class
1981+
=====================
1982+
1983+
Objects of this class are returned by :ref:`SODA <soda>` in the ``_id``
1984+
attribute of documents stored in native collections when using Oracle Database
1985+
23.4 (and later). It is a subclass of the `bytes <https://docs.python.org/3/
1986+
library/stdtypes.html#bytes>`__ class.
1987+
1988+
.. versionadded:: 2.1.0
1989+
1990+
.. dbapimethodextension::

doc/src/api_manual/variable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Variable Class
1111

1212
.. autoclass:: Var
1313

14-
An Var object should be created with :meth:`Cursor.var()` or
14+
A Var object should be created with :meth:`Cursor.var()` or
1515
:meth:`Cursor.arrayvar()`.
1616

1717
.. dbapiobjectextension::

doc/src/user_guide/connection_handling.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,10 +2468,10 @@ immediately return an available connection. Some users set larger
24682468
``increment`` values even for fixed-size pools because it can help a pool
24692469
re-establish itself if all connections become invalid, for example after a
24702470
network dropout. In the common case of Thin mode with the default ``getmode``
2471-
of ``POOL_GETMODE_WAIT``, any :meth:`~ConnectionPool.acquire()` call that
2472-
initiates pool growth will return after the first new connection is created,
2473-
regardless of how big ``increment`` is. The pool will then continue to
2474-
re-establish connections in a background thread.
2471+
of :data:`oracledb.POOL_GETMODE_WAIT`, any :meth:`~ConnectionPool.acquire()`
2472+
call that initiates pool growth will return after the first new connection is
2473+
created, regardless of how big ``increment`` is. The pool will then continue
2474+
to re-establish connections in a background thread.
24752475

24762476
A connection pool can shrink back to its minimum size ``min`` when connections
24772477
opened by the pool are not used by the application. This frees up database

doc/src/user_guide/initialization.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,3 +704,23 @@ V$SESSION_CONNECT_INFO and verifying if the value of the column begins with the
704704
text ``python-oracledb thn``. See :ref:`vsessconinfo`.
705705

706706
Note all connections in a python-oracledb application must use the same mode.
707+
708+
.. _settingdefaults:
709+
710+
Changing python-oracledb Default Settings
711+
=========================================
712+
713+
Python-oracledb has a singleton :ref:`Defaults <defaults>` object with
714+
attributes that set default behaviors of the driver. The object is accessed
715+
using the :data:`defaults` attribute of the imported driver.
716+
717+
For example, to return queried LOB columns directly as strings or bytes:
718+
719+
.. code-block:: python
720+
721+
import oracledb
722+
723+
oracledb.defaults.fetch_lobs = False
724+
725+
726+
See :ref:`defaultsattributes` for the attributes that can be set.

0 commit comments

Comments
 (0)