Skip to content

Commit 0953325

Browse files
Use enumerations for all integer constants.
1 parent b31518b commit 0953325

16 files changed

+389
-152
lines changed

doc/src/api_manual/module.rst

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,17 +2430,26 @@ constants used in advanced queuing.
24302430
Connection Authorization Modes
24312431
------------------------------
24322432

2433-
These constants are extensions to the DB API definition and have deprecated the
2434-
`authorization modes <https://cx-oracle.readthedocs.io/en/latest/api_manual/
2435-
module.html#connection-authorization-modes>`_ used in cx_Oracle 8.3. They are
2436-
possible values for the ``mode`` parameter of the :meth:`connect()` method.
2433+
These constants belong to the enumeration called ``AuthMode``. The constants
2434+
listed below are extensions to the DB API definition and have
2435+
deprecated the `authorization modes <https://cx-oracle.readthedocs.io/en/
2436+
latest/api_manual/module.html#connection-authorization-modes>`_ used in
2437+
cx_Oracle 8.3. They are possible values for the ``mode`` parameter of the
2438+
:meth:`connect()` method.
24372439

2440+
.. versionchanged:: 2.3.0
2441+
2442+
The integer constants for the connection authorization modes were replaced
2443+
with the enumeration ``AuthMode``.
24382444

24392445
.. data:: AUTH_MODE_DEFAULT
24402446

24412447
This constant is used to specify that default authentication is to take
24422448
place. This is the default value if no mode is passed at all.
24432449

2450+
This enumerated value can also be identified by
2451+
``oracledb.AuthMode.DEFAULT``.
2452+
24442453
.. note::
24452454

24462455
This constant can be used for standalone and pooled connections in the
@@ -2455,6 +2464,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
24552464
This constant is used to specify that preliminary authentication is to be
24562465
used. This is needed for performing database startup and shutdown.
24572466

2467+
This enumerated value can also be identified by
2468+
``oracledb.AuthMode.PRELIM``.
2469+
24582470
.. note::
24592471

24602472
This constant can only be used in the python-oracledb Thick mode for
@@ -2467,6 +2479,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
24672479

24682480
This constant is used to specify that SYSASM access is to be acquired.
24692481

2482+
This enumerated value can also be identified by
2483+
``oracledb.AuthMode.SYSASM``.
2484+
24702485
.. note::
24712486

24722487
This constant can be used for standalone and pooled connections in the
@@ -2480,6 +2495,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
24802495

24812496
This constant is used to specify that SYSBACKUP access is to be acquired.
24822497

2498+
This enumerated value can also be identified by
2499+
``oracledb.AuthMode.SYSBKP``.
2500+
24832501
.. note::
24842502

24852503
This constant can be used for standalone and pooled connections in the
@@ -2493,6 +2511,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
24932511

24942512
This constant is used to specify that SYSDBA access is to be acquired.
24952513

2514+
This enumerated value can also be identified by
2515+
``oracledb.AuthMode.SYSDBA``.
2516+
24962517
.. note::
24972518

24982519
This constant can be used for standalone and pooled connections in the
@@ -2506,6 +2527,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
25062527

25072528
This constant is used to specify that SYSDG access is to be acquired.
25082529

2530+
This enumerated value can also be identified by
2531+
``oracledb.AuthMode.SYSDGD``.
2532+
25092533
.. note::
25102534

25112535
This constant can be used for standalone and pooled connections in the
@@ -2519,6 +2543,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
25192543

25202544
This constant is used to specify that SYSKM access is to be acquired.
25212545

2546+
This enumerated value can also be identified by
2547+
``oracledb.AuthMode.SYSKMT``.
2548+
25222549
.. note::
25232550

25242551
This constant can be used for standalone and pooled connections in the
@@ -2532,6 +2559,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
25322559

25332560
This constant is used to specify that SYSOPER access is to be acquired.
25342561

2562+
This enumerated value can also be identified by
2563+
``oracledb.AuthMode.SYSOPER``.
2564+
25352565
.. note::
25362566

25372567
This constant can be used for standalone and pooled connections in the
@@ -2545,6 +2575,9 @@ possible values for the ``mode`` parameter of the :meth:`connect()` method.
25452575

25462576
This constant is used to specify that SYSRAC access is to be acquired.
25472577

2578+
This enumerated value can also be identified by
2579+
``oracledb.AuthMode.SYSRAC``.
2580+
25482581
.. note::
25492582

25502583
This constant can be used for standalone and pooled connections in the
@@ -2714,18 +2747,26 @@ also used by the :attr:`MessageTable.operation` or
27142747
Connection Pool Get Modes
27152748
-------------------------
27162749

2717-
These constants are extensions to the DB API definition and have deprecated the
2750+
These constants belong to the enumeration called ``PoolGetMode``. The constants
2751+
listed below are extensions to the DB API definition and have deprecated the
27182752
`Session Pool Get Modes <https://cx-oracle.readthedocs.io/en/latest/api_manual/
27192753
module.html#session-pool-get-modes>`_ constants that were used in cx_Oracle
27202754
8.3. They are possible values for the ``getmode`` parameter of the
27212755
:meth:`oracledb.create_pool()` method.
27222756

2757+
.. versionchanged:: 2.3.0
2758+
2759+
The integer constants for the connection pool get modes were replaced
2760+
with the enumeration ``PoolGetMode``.
27232761

27242762
.. data:: POOL_GETMODE_FORCEGET
27252763

27262764
This constant is used to specify that a new connection will be returned if
27272765
there are no free sessions available in the pool.
27282766

2767+
This enumerated value can also be identified by
2768+
``oracledb.PoolGetMode.FORCEGET``.
2769+
27292770
.. note::
27302771

27312772
This constant deprecates the ``SPOOL_ATTRVAL_FORCEGET`` constant that
@@ -2737,6 +2778,9 @@ module.html#session-pool-get-modes>`_ constants that were used in cx_Oracle
27372778
This constant is used to specify that an exception should be raised if
27382779
there are no free sessions available in the pool.
27392780

2781+
This enumerated value can also be identified by
2782+
``oracledb.PoolGetMode.NOWAIT``.
2783+
27402784
.. note::
27412785

27422786
This constant deprecates the ``SPOOL_ATTRVAL_NOWAIT`` constant that was
@@ -2749,6 +2793,9 @@ module.html#session-pool-get-modes>`_ constants that were used in cx_Oracle
27492793
session is available if there are no free sessions available in the pool.
27502794
This is the default value.
27512795

2796+
This enumerated value can also be identified by
2797+
``oracledb.PoolGetMode.WAIT``.
2798+
27522799
.. note::
27532800

27542801
This constant deprecates the ``SPOOL_ATTRVAL_WAIT`` constant that was
@@ -2761,6 +2808,9 @@ module.html#session-pool-get-modes>`_ constants that were used in cx_Oracle
27612808
of time (defined by the ``wait_timeout`` parameter) for a session to become
27622809
available before returning with an error.
27632810

2811+
This enumerated value can also be identified by
2812+
``oracledb.PoolGetMode.TIMEDWAIT``.
2813+
27642814
.. note::
27652815

27662816
This constant deprecates the ``SPOOL_ATTRVAL_TIMEDWAIT`` constant that
@@ -2771,18 +2821,27 @@ module.html#session-pool-get-modes>`_ constants that were used in cx_Oracle
27712821
Connection Pool Purity Constants
27722822
--------------------------------
27732823

2774-
These constants are extensions to the DB API definition and have deprecated the
2824+
These constants belong to the enumeration called ``Purity``. The constants
2825+
listed below are extensions to the DB API definition and have deprecated the
27752826
`Session Pool Purity <https://cx-oracle.readthedocs.io/en/latest/api_manual/
27762827
module.html#session-pool-purity>`_ constants that were used in cx_Oracle 8.3.
27772828
They are possible values for the ``purity`` parameter of the :meth:`connect()`
27782829
method, which is used in Database Resident Connection Pooling (DRCP).
27792830

2831+
.. versionchanged:: 2.3.0
2832+
2833+
The integer constants for the connection pool get modes were replaced
2834+
with the enumeration ``Purity``.
2835+
27802836
.. data:: PURITY_DEFAULT
27812837

27822838
This constant is used to specify that the purity of the session is the
27832839
default value identified by Oracle (see Oracle's documentation for more
27842840
information). This is the default value.
27852841

2842+
This enumerated value can also be identified by
2843+
``oracledb.Purity.DEFAULT``.
2844+
27862845
.. note::
27872846

27882847
This constant deprecates the ``ATTR_PURITY_DEFAULT`` constant that was
@@ -2793,6 +2852,8 @@ method, which is used in Database Resident Connection Pooling (DRCP).
27932852
This constant is used to specify that the session acquired from the pool
27942853
should be new and not have any prior session state.
27952854

2855+
This enumerated value can also be identified by ``oracledb.Purity.NEW``.
2856+
27962857
.. note::
27972858

27982859
This constant deprecates the ``ATTR_PURITY_NEW`` constant that was used
@@ -2804,6 +2865,8 @@ method, which is used in Database Resident Connection Pooling (DRCP).
28042865
This constant is used to specify that the session acquired from the pool
28052866
need not be new and may have prior session state.
28062867

2868+
This enumerated value can also be identified by ``oracledb.Purity.SELF``.
2869+
28072870
.. note::
28082871

28092872
This constant deprecates the ``ATTR_PURITY_SELF`` constant that was
@@ -3404,26 +3467,40 @@ below.
34043467
Vector Format Constants
34053468
-----------------------
34063469

3407-
These constants are possible values for the :attr:`FetchInfo.vector_format`
3408-
attribute.
3470+
These constants belong to the enumeration called ``VectorFormat`` and are
3471+
possible values for the :attr:`FetchInfo.vector_format` attribute.
34093472

34103473
.. versionadded:: 2.2.0
34113474

3475+
.. versionchanged:: 2.3.0
3476+
3477+
The integer constants for the vector format constants were replaced with
3478+
the enumeration ``VectorFormat``.
3479+
34123480
.. data:: VECTOR_FORMAT_FLOAT32
34133481

34143482
This constant is used to represent the storage format of VECTOR columns
34153483
using 32-bit floating point numbers.
34163484

3485+
This enumerated value can also be identified by
3486+
``oracledb.VectorFormat.FLOAT32``.
3487+
34173488
.. data:: VECTOR_FORMAT_FLOAT64
34183489

34193490
This constant is used to represent the storage format of VECTOR columns
34203491
using 64-bit floating point numbers.
34213492

3493+
This enumerated value can also be identified by
3494+
``oracledb.VectorFormat.FLOAT64``.
3495+
34223496
.. data:: VECTOR_FORMAT_INT8
34233497

34243498
This constant is used to represent the storage format of VECTOR columns
34253499
using 8-bit signed integers.
34263500

3501+
This enumerated value can also be identified by
3502+
``oracledb.VectorFormat.INT8``.
3503+
34273504
.. _exceptions:
34283505

34293506
Oracledb Exceptions

doc/src/release_notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ Thick Mode Changes
3232
Common Changes
3333
++++++++++++++
3434

35+
#) Replaced integer constants for
36+
:ref:`connection authorization modes <connection-authorization-modes>`,
37+
:ref:`connection pool get modes <connpoolmodes>`,
38+
:ref:`connection pool purity constants <drcppurityconsts>` and
39+
:ref:`vector format constants <vectorformatconstants>` with
40+
`enumerations <https://docs.python.org/3/library/enum.html>`__ in order to
41+
provide a more useful repr() and improve type safety, among other things.
3542
#) The default value of the ``tcp_connect_timeout`` parameter was changed
3643
from 60 seconds to 20 seconds. The default value of the
3744
``retry_delay`` parameter was changed from 0 seconds to 1 second.

src/oracledb/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@
8181
NUMBER as NUMBER,
8282
ROWID as ROWID,
8383
STRING as STRING,
84+
)
85+
86+
from .enums import (
8487
# authentication modes
88+
AuthMode as AuthMode,
8589
AUTH_MODE_DEFAULT as AUTH_MODE_DEFAULT,
8690
AUTH_MODE_PRELIM as AUTH_MODE_PRELIM,
8791
AUTH_MODE_SYSASM as AUTH_MODE_SYSASM,
@@ -92,15 +96,18 @@
9296
AUTH_MODE_SYSOPER as AUTH_MODE_SYSOPER,
9397
AUTH_MODE_SYSRAC as AUTH_MODE_SYSRAC,
9498
# pool "get" modes
99+
PoolGetMode as PoolGetMode,
95100
POOL_GETMODE_WAIT as POOL_GETMODE_WAIT,
96101
POOL_GETMODE_NOWAIT as POOL_GETMODE_NOWAIT,
97102
POOL_GETMODE_FORCEGET as POOL_GETMODE_FORCEGET,
98103
POOL_GETMODE_TIMEDWAIT as POOL_GETMODE_TIMEDWAIT,
99104
# purity values
105+
Purity as Purity,
100106
PURITY_DEFAULT as PURITY_DEFAULT,
101107
PURITY_NEW as PURITY_NEW,
102108
PURITY_SELF as PURITY_SELF,
103109
# vector formats
110+
VectorFormat as VectorFormat,
104111
VECTOR_FORMAT_FLOAT32 as VECTOR_FORMAT_FLOAT32,
105112
VECTOR_FORMAT_FLOAT64 as VECTOR_FORMAT_FLOAT64,
106113
VECTOR_FORMAT_INT8 as VECTOR_FORMAT_INT8,

0 commit comments

Comments
 (0)