Skip to content

Commit 673df27

Browse files
Added method is_thin_mode() as suggested (#10).
1 parent 39ee1c1 commit 673df27

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

doc/src/api_manual/module.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,26 @@ Oracledb Methods
854854
This method is an extension to the DB API definition.
855855

856856

857+
.. function:: is_thin_mode()
858+
859+
Returns a boolean indicating if Thin mode is in use.
860+
861+
Immediately after python-oracledb is imported, this function will return
862+
True indicating that python-oracledb defaults to Thin mode. If
863+
:func:`oracledb.init_oracle_client()` is called, then a subsequent call to
864+
``is_thin_mode()`` will return False indicating that Thick mode is
865+
enabled. Once the first standalone connection or connection pool is
866+
created, or a call to ``oracledb.init_oracle_client()`` is made, then
867+
python-oracledb’s mode is fixed and the value returned by
868+
``is_thin_mode()`` will never change for the lifetime of the process.
869+
870+
The attribute :attr:`Connection.thin` can be used to check a connection's
871+
mode.
872+
873+
.. note::
874+
875+
This method is an extension to the DB API definition.
876+
857877
.. function:: makedsn(host, port, sid=None, service_name=None, region=None, \
858878
sharding_key=None, super_sharding_key=None)
859879

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Common Changes
4040
#) The compiler flag ``-arch x86_64`` no longer needs to be explicitly
4141
specified when building from source code on macOS (Intel x86) without
4242
Universal Python binaries.
43+
#) Added method :func:`oracledb.is_thin_mode()` to support determining whether
44+
the driver is using thin mode or not
45+
(`issue 16 <https://github.com/oracle/python-oracledb/issues/10>`__).
4346
#) Improved samples and documentation.
4447

4548

src/oracledb/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from .var import Var
4646
from .constructors import *
4747
from .dsn import makedsn
48+
from .driver_mode import is_thin_mode
4849

4950
from .base_impl import *
5051
from .thick_impl import clientversion, init_oracle_client

src/oracledb/driver_mode.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,23 @@ def check_and_return_mode(requested_thin_mode=None):
6868
elif requested_thin_mode is not None and requested_thin_mode != thin_mode:
6969
errors._raise_err(errors.ERR_THIN_CONNECTION_ALREADY_CREATED)
7070
return thin_mode
71+
72+
73+
def is_thin_mode() -> bool:
74+
"""
75+
Return a boolean specifying whether the driver is using thin mode (True) or
76+
thick mode (False).
77+
78+
Immediately after python-oracledb is imported, this function will return
79+
True indicating that python-oracledb defaults to Thin mode. If
80+
oracledb.init_oracle_client() is called, then a subsequent call to
81+
is_thin_mode() will return False indicating that Thick mode is enabled.
82+
Once the first standalone connection or connection pool is created, or a
83+
call to oracledb.init_oracle_client() is made, then python-oracledb's mode
84+
is fixed and the value returned by is_thin_mode() will never change for the
85+
lifetime of the process.
86+
87+
"""
88+
if thin_mode is not None:
89+
return thin_mode
90+
return True

0 commit comments

Comments
 (0)