Skip to content

Commit 92fb448

Browse files
Improve calculation of default configuration directory.
1 parent 6b2a7d5 commit 92fb448

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

doc/src/release_notes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ Thin Mode Changes
7272
Thick Mode Changes
7373
++++++++++++++++++
7474

75+
#) The value of :attr:`defaults.config_dir` is now calculated from the
76+
location of the Oracle Client shared library on some platforms. If a value
77+
is supplied to the ``config_dir`` parameter of
78+
:meth:`oracledb.init_oracle_client()`, then the value of
79+
:attr:`defaults.config_dir` is set to that value after the call completes
80+
successfully.
7581
#) Fixed bug that caused :attr:`oracledb._Error.isrecoverable` to always be
7682
`False`.
7783

@@ -88,6 +94,9 @@ Common Changes
8894
#) Added :meth:`oracledb.register_password_type()` to allow users to register
8995
a function that will be called when a password is supplied as a dictionary
9096
containing the key "type".
97+
#) Set the default value of :attr:`defaults.config_dir` to
98+
``$ORACLE_HOME/network/admin`` if the environment variable ``ORACLE_HOME``
99+
is set.
91100
#) All connect strings are parsed by the driver if the new parameter
92101
``thick_mode_dsn_passthrough`` is set to *True*. Previously, only Thin
93102
mode parsed all connect strings and Thick mode passed the connect string

src/oracledb/impl/base/defaults.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ cdef class DefaultsImpl:
3333
def __init__(self):
3434
self.arraysize = 100
3535
self.config_dir = os.environ.get("TNS_ADMIN")
36+
if self.config_dir is None:
37+
oracle_home = os.environ.get("ORACLE_HOME")
38+
if oracle_home is not None:
39+
self.config_dir = os.path.join(oracle_home, "network", "admin")
3640
self.fetch_lobs = True
3741
self.fetch_decimals = False
3842
self.prefetchrows = 2

src/oracledb/impl/thick/utils.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -531,6 +531,8 @@ def init_oracle_client(lib_dir=None, config_dir=None, error_url=None,
531531
params.useJsonId = True
532532
if config_dir is None:
533533
config_dir = C_DEFAULTS.config_dir
534+
else:
535+
C_DEFAULTS.config_dir = config_dir
534536
if lib_dir is not None:
535537
if isinstance(lib_dir, bytes):
536538
lib_dir_bytes = lib_dir
@@ -558,6 +560,8 @@ def init_oracle_client(lib_dir=None, config_dir=None, error_url=None,
558560
&params, &driver_info.context,
559561
&error_info) < 0:
560562
_raise_from_info(&error_info)
563+
if config_dir is None and params.oracleClientConfigDir != NULL:
564+
C_DEFAULTS.config_dir = params.oracleClientConfigDir.decode()
561565
if dpiContext_getClientVersion(driver_info.context,
562566
&driver_info.client_version_info) < 0:
563567
_raise_from_odpi()

0 commit comments

Comments
 (0)