Skip to content

Commit 57e5b9c

Browse files
Samll documentation changes.
1 parent 4c4a2f5 commit 57e5b9c

File tree

8 files changed

+110
-51
lines changed

8 files changed

+110
-51
lines changed

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copyright (c) 2016, 2024, Oracle and/or its affiliates.
1+
Copyright (c) 2016, 2025, Oracle and/or its affiliates.

doc/src/api_manual/deprecations.rst

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ python-oracledb. The relevant functionality may be removed in a future version
1515
of python-oracledb. The cx_Oracle driver itself is obsolete and should not be
1616
used for new development.
1717

18+
.. list-table-with-summary:: Deprecated in python-oracledb 3.4
19+
:header-rows: 1
20+
:class: wy-table-responsive
21+
:summary: The first column, Name, displays the deprecated feature. The second column, Comments, includes information about the deprecation and the replacement to use, if applicable.
22+
:name: _deprecations_3_4
23+
24+
* - Name
25+
- Comments
26+
* - The x86_64 macOS and 32-bit Windows platforms are deprecated. They will be desupported when the `cryptography <https://pypi.org/project/cryptography/>`__ package desupports them, see the `cryptography deprecation announcement <https://mail.python.org/archives/list/python-announce-list@python.org/thread/R4BZNC36MSFLKULA74KILLFY6GP3VCPA/>`__.
27+
- Use arm64 macOS or 64-bit Windows instead.
28+
1829
.. list-table-with-summary:: Deprecated in python-oracledb 3.0
1930
:header-rows: 1
2031
:class: wy-table-responsive
@@ -24,8 +35,7 @@ used for new development.
2435
* - Name
2536
- Comments
2637
* - Parameter ``pool`` of :meth:`oracledb.connect()` and :meth:`oracledb.connect_async()`
27-
- Use :meth:`ConnectionPool.acquire()`, or make use of the
28-
:ref:`connection pool cache <connpoolcache>` instead
38+
- Use :meth:`ConnectionPool.acquire()`, or make use of the :ref:`connection pool cache <connpoolcache>` instead
2939

3040
.. list-table-with-summary:: Desupported in python-oracledb 2.0
3141
:header-rows: 1
@@ -36,33 +46,21 @@ used for new development.
3646
* - Name
3747
- Comments
3848
* - ``oracledb.__future__.old_json_col_as_obj``
39-
- VARCHAR2 and LOB columns created with the ``IS JSON`` check constraint
40-
are now always fetched as JSON. Use an :ref:`output type handler
41-
<outputtypehandlers>` if the old behavior is required.
42-
* - Parameters ``encoding`` and ``nencoding`` of :func:`oracledb.connect()`
43-
and :func:`oracledb.create_pool()`, and the related attributes on the
44-
objects created
45-
- The driver encodings are always UTF-8. Remove uses of ``encoding`` and
46-
``nencoding`` from your code.
47-
* - Parameter ``threaded`` of :func:`oracledb.connect()` and
48-
:func:`oracledb.create_pool()`
49+
- VARCHAR2 and LOB columns created with the ``IS JSON`` check constraint are now always fetched as JSON. Use an :ref:`output type handler <outputtypehandlers>` if the old behavior is required.
50+
* - Parameters ``encoding`` and ``nencoding`` of :func:`oracledb.connect()` and :func:`oracledb.create_pool()`, and the related attributes on the objects created
51+
- The driver encodings are always UTF-8. Remove uses of ``encoding`` and ``nencoding`` from your code.
52+
* - Parameter ``threaded`` of :func:`oracledb.connect()` and :func:`oracledb.create_pool()`
4953
- Threading is always used. Remove uses of ``threaded`` from your code.
50-
* - Parameter ``waitTimeout`` of :func:`oracledb.create_pool()` and
51-
``oracledb.SessionPool()``
54+
* - Parameter ``waitTimeout`` of :func:`oracledb.create_pool()` and ``oracledb.SessionPool()``
5255
- Replace with parameter ``wait_timeout``
53-
* - Parameter ``maxLifetimeSession`` of :func:`oracledb.create_pool()` and
54-
``oracledb.SessionPool()``
56+
* - Parameter ``maxLifetimeSession`` of :func:`oracledb.create_pool()` and ``oracledb.SessionPool()``
5557
- Replace with parameter ``max_lifetime_session``
56-
* - Parameter ``sessionCallback`` of :func:`oracledb.create_pool()` and
57-
``oracledb.SessionPool()``
58+
* - Parameter ``sessionCallback`` of :func:`oracledb.create_pool()` and ``oracledb.SessionPool()``
5859
- Replace with parameter ``session_callback``
59-
* - Parameter ``maxSessionsPerShard`` of :func:`oracledb.create_pool()` and
60-
``oracledb.SessionPool()``
60+
* - Parameter ``maxSessionsPerShard`` of :func:`oracledb.create_pool()` and ``oracledb.SessionPool()``
6161
- Replace with parameter ``max_sessions_per_shard``
62-
* - Attribute ``maxBytesPerCharacter`` of the :ref:`Connection object
63-
<connobj>`
64-
- The driver encodings are always UTF-8 so this attribute can be replaced by
65-
the constant value 4
62+
* - Attribute ``maxBytesPerCharacter`` of the :ref:`Connection object <connobj>`
63+
- The driver encodings are always UTF-8 so this attribute can be replaced by the constant value 4
6664
* - ``Connection.tnsentry``
6765
- Replace with :attr:`Connection.dsn`
6866
* - ``SessionPool.tnsentry``
@@ -76,16 +74,11 @@ used for new development.
7674

7775
* - Name
7876
- Comments
79-
* - Calling :meth:`Variable.setvalue()` with a string value when the
80-
variable type is one of :data:`oracledb.DB_TYPE_BLOB`,
77+
* - Calling :meth:`Variable.setvalue()` with a string value when the variable type is one of :data:`oracledb.DB_TYPE_BLOB`,
8178
:data:`oracledb.DB_TYPE_CLOB` or :data:`oracledb.DB_TYPE_NCLOB`.
82-
- Call :meth:`Connection.createlob()` with the value instead and pass the
83-
result to :meth:`Variable.setvalue()`.
84-
* - Setting an attribute of type :data:`oracledb.DB_TYPE_BLOB`,
85-
:data:`oracledb.DB_TYPE_CLOB` or :data:`oracledb.DB_TYPE_NCLOB` on a
86-
database object to a string value.
87-
- Call :meth:`Connection.createlob()` with the value instead and set the
88-
attribute with the result.
79+
- Call :meth:`Connection.createlob()` with the value instead and pass the result to :meth:`Variable.setvalue()`.
80+
* - Setting an attribute of type :data:`oracledb.DB_TYPE_BLOB`, :data:`oracledb.DB_TYPE_CLOB` or :data:`oracledb.DB_TYPE_NCLOB` on a database object to a string value.
81+
- Call :meth:`Connection.createlob()` with the value instead and set the attribute with the result.
8982

9083
.. list-table-with-summary:: Deprecated in python-oracledb 1.4
9184
:header-rows: 1
@@ -95,10 +88,8 @@ used for new development.
9588

9689
* - Name
9790
- Comments
98-
* - Output type handler with arguments
99-
``handler(cursor, name, default_type, length, precision, scale)``
100-
- Replace with ``handler(cursor, metadata)``. See
101-
:ref:`outputtypehandlers`.
91+
* - Output type handler with arguments ``handler(cursor, name, default_type, length, precision, scale)``
92+
- Replace with ``handler(cursor, metadata)``. See :ref:`outputtypehandlers`.
10293

10394
.. list-table-with-summary:: Deprecated in python-oracledb 1.0
10495
:header-rows: 1

doc/src/release_notes.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ Common Changes
6060
support and :ref:`Cloud Native Authentication <cloudnativemodules>`
6161
support
6262
(`issue 512 <https://github.com/oracle/python-oracledb/issues/512>`__).
63+
#) The x86_64 macOS and 32-bit Windows platforms are :ref:`deprecated
64+
<deprecations>`. They will be desupported when the `cryptography
65+
<https://pypi.org/project/cryptography/>`__ package desupports them, see
66+
the `cryptography deprecation announcement <https://mail.python.org/
67+
archives/list/python-announce-list@python.org/thread/
68+
R4BZNC36MSFLKULA74KILLFY6GP3VCPA/>`__.
6369
#) Pin Cython to 3.1.x instead of 3.1.0 as requested
6470
(`issue 530 <https://github.com/oracle/python-oracledb/issues/530>`__).
6571
#) Fixed bug when attempting to execute an empty statement
@@ -69,7 +75,8 @@ Common Changes
6975
#) Fixed bug when attempting to append an element to a
7076
:ref:`DbObject <dbobjecttype>` which is not actually a collection.
7177
#) API documentation is now generated from the source code.
72-
#) Internal change: typing_extensions is now a dependency.
78+
#) Internal change: `typing_extensions <https://pypi.org/project/
79+
typing-extensions/>`__ is now a dependency.
7380

7481

7582
oracledb `3.3.0 <https://github.com/oracle/python-oracledb/compare/v3.2.0...v3.3.0>`__ (July 2025)

doc/src/user_guide/batch_statement.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,14 @@ be beneficial.
494494
See `samples/load_csv.py <https://github.com/oracle/python-oracledb/tree/main/
495495
samples/load_csv.py>`__ for a runnable example.
496496

497+
You should also review whether Oracle's specialized data loading tools and
498+
features suit your environment. These can be faster than using Python. See
499+
`SQL*Loader <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=
500+
GUID-DD843EE2-1FAB-4E72-A115-21D97A501ECC>`__ and `External Tables
501+
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=
502+
GUID-44323E01-7D72-45EC-915A-99E596769D9E>`__.
503+
504+
497505
Creating CSV Files from Oracle Database
498506
---------------------------------------
499507

doc/src/user_guide/initialization.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ More details and options are shown in the later sections:
106106
use Thin mode. The features supported by Thin mode can be found in
107107
:ref:`featuresummary`.
108108

109-
- On any operating system, if you set ``lib_dir`` to the library directory of a
110-
full database or full client installation (such as from running
111-
``runInstaller``), you will need to have previously set the Oracle environment,
112-
for example by setting the ``ORACLE_HOME`` environment variable. Otherwise you
113-
will get errors like ``ORA-1804``. You should set this variable, and other
114-
Oracle environment variables, before starting Python, as shown in :ref:`Oracle
115-
Environment Variables <envset>`.
109+
- On any operating system, if you set the ``lib_dir`` parameter to the library
110+
directory of a full database or full client installation (such as from
111+
running ``runInstaller``), you will need to have previously set the Oracle
112+
environment, for example by setting the ``ORACLE_HOME`` environment
113+
variable. Otherwise you will get errors like ``ORA-1804``. You should set
114+
this variable, and other Oracle environment variables, before starting
115+
Python, as shown in :ref:`Oracle Environment Variables <envset>`.
116116

117117
- The :meth:`~oracledb.init_oracle_client()` function may be called multiple
118118
times in your application but must always pass the same arguments.

doc/src/user_guide/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ architecture. Note Oracle Database 23ai 32-bit clients are not available on any
526526
platform, however you can use older 32-bit clients to connect to Oracle
527527
Database 23ai.
528528

529-
1. Set required Oracle environment variables by running the Oracle environment
530-
script. For example:
529+
1. Set required Oracle environment variables, such as ``ORACLE_HOME``, by
530+
running the Oracle environment script. For example:
531531

532532
.. code-block:: shell
533533

doc/src/user_guide/sql_execution.rst

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,60 @@ Changing Query Results with Rowfactories
494494
Python-oracledb "rowfactories" are methods called for each row retrieved from
495495
the database. The :meth:`Cursor.rowfactory` method is called with the tuple
496496
fetched from the database before it is returned to the application. The method
497-
can convert the tuple to a different value.
497+
can convert the tuple to a different value or representation.
498+
499+
A rowfactory should be set on a cursor after a call to :meth:`Cursor.execute()`
500+
before fetching data from the cursor. Calling :meth:`~Cursor.execute()` again
501+
will clear any previous rowfactory.
502+
503+
**Fetching Rows using a Data Class**
504+
505+
Python `Data Classes <https://docs.python.org/3/library/dataclasses.html>`__
506+
provide a simple way to encapsulate data. An example of using them with a query
507+
rowfactory is:
508+
509+
.. code-block:: python
510+
511+
import dataclasses
512+
import datetime
513+
514+
. . .
515+
516+
@dataclasses.dataclass
517+
class MyRow:
518+
employee_id: int
519+
last_name: str
520+
hire_date: datetime.datetime
521+
522+
cursor.execute(
523+
"""select employee_id, last_name, hire_date
524+
from employees
525+
where employee_id < 105
526+
order by employee_id""")
527+
528+
cursor.rowfactory = MyRow
529+
530+
for row in cursor:
531+
print("Number:", row.employee_id)
532+
print("Name:", row.last_name)
533+
print("Hire Date:", row.hire_date)
534+
535+
The output is::
536+
537+
Number: 100
538+
Name: King
539+
Hire Date: 2003-06-17 00:00:00
540+
Number: 101
541+
Name: Kochhar
542+
Hire Date: 2005-09-21 00:00:00
543+
Number: 102
544+
Name: De Haan
545+
Hire Date: 2001-01-13 00:00:00
498546

499547
**Fetching Rows as Dictionaries**
500548

501-
For example, to fetch each row of a query as a dictionary:
549+
To fetch each row of a query as a dictionary, you can use
550+
:meth:`Cursor.rowfactory` like:
502551

503552
.. code-block:: python
504553
@@ -515,7 +564,8 @@ The output is::
515564
'POSTAL_CODE': '00989', 'CITY': 'Roma', 'STATE_PROVINCE': None,
516565
'COUNTRY_ID': 'IT'}
517566

518-
Also see how ``JSON_OBJECT`` is used in :ref:`jsondatatype`.
567+
Also see how ``JSON_OBJECT`` is used in :ref:`jsondatatype`, since querying
568+
directly as JSON may be preferable.
519569

520570
If you join tables where the same column name occurs in both tables with
521571
different meanings or values, then use a column alias in the query. Otherwise,

src/oracledb/cursor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ def rowfactory(self) -> Callable:
455455
each row but if this attribute is set, the method is called with the
456456
tuple that would normally be returned, and the result of the method is
457457
returned instead.
458+
459+
The ``rowfactory`` attribute should be set after each statement
460+
execution before data is fetched from the cursor.
458461
"""
459462
self._verify_open()
460463
return self._impl.rowfactory

0 commit comments

Comments
 (0)