Database version: Oracle 19.17.0.0.0
platform.platform: Linux-5.4.17-2136.313.6.el7uek.x86_64-x86_64-with-glibc2.17
sys.maxsize > 2**32: True
platform.python_version: 3.9.16
oracledb.version: 1.2.1
Is it an error or a hang or a crash?
Error
What error(s) or behavior you are seeing?
When calling the connect
function for a bequeath connection, like:
connection = oracledb.connect(mode=oracledb.AUTH_MODE_SYSDBA)
The following error occurs:
Traceback (most recent call last):
File "example_failing_bequeath_connection.py", line 11, in <module>
connection = oracledb.connect(mode=sysdba_mode)
File "/home/john/python3_oracledb_121/lib/python3.9/site-packages/oracledb/connection.py", line 1013, in connect
return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
File "/home/john/python3_oracledb_121/lib/python3.9/site-packages/oracledb/connection.py", line 138, in __init__
impl.connect(params_impl, pool_impl)
File "src/oracledb/impl/thick/connection.pyx", line 387, in oracledb.thick_impl.ThickConnImpl.connect
File "src/oracledb/impl/thick/utils.pyx", line 410, in oracledb.thick_impl._raise_from_odpi
File "src/oracledb/impl/thick/utils.pyx", line 400, in oracledb.thick_impl._raise_from_info
oracledb.exceptions.DatabaseError: ORA-12545: Connect failed because target host or object does not exist
Does your application call init_oracle_client()?
Yes, running in thick mode.
Include a runnable Python script that shows the problem.
import os
import oracledb
os.environ["ORACLE_HOME"] = "/u01/app/oracle/product/19.0.0.0/db_1"
os.environ["ORACLE_SID"] = "ORCL"
oracledb.init_oracle_client()
connection = oracledb.connect(mode=oracledb.AUTH_MODE_SYSDBA)
connection.close()
When running in debug mode I found that the connection is being made using the connect_string:
'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=None)(PORT=1521)))(CONNECT_DATA=)(SECURITY=(SSL_SERVER_DN_MATCH=ON)))'
This explains the ORA-12545 error message.
It looks like a regression bug in src/oracledb/impl/base/connect_params.pyx
, in the get_connect_string
function (commit 847004a) introduced in version 1.2.0.
In version 1.0.1 a fix was included to 'restore support for bequeath connection` (commit 5852bae), but the change in 1.2.0 altered the same line. In version 1.1.1 the error does not occur.
Just for testing purposes, I changed the code as follows and then bequeath connections are working fine:
--- a/src/oracledb/impl/base/connect_params.pyx
+++ b/src/oracledb/impl/base/connect_params.pyx
@@ -538,7 +538,7 @@ cdef class ConnectParamsImpl:
will be a connect string built up from the components supplied when the
object was built.
"""
- if self._has_components:
+ if self._has_components and self._default_address.host is not None:
return self.description_list.build_connect_string()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4