python-oracledb icon indicating copy to clipboard operation
python-oracledb copied to clipboard

Expose service names available in tnsnames.ora

Open mac-vtl opened this issue 11 months ago • 4 comments

  1. Describe your new request in detail

python-oracledb internally parses the content of the tnsnames.ora file here but does not provide or expose a way to list the available service names parsed.

We have use cases where we need to switch between database services. It would be logical to propose the list of available services from the list of services parsed by python-oracledb.

Something like below or similar would work:

from oracledb.connect_params import ConnectParams
params = ConnectParamsImpl()
service_names = params.available_service_names()
# do something with service_names
print(service_names)

Is that something feasible? What are your thoughts?

  1. Give supporting information about tools and operating systems. Give relevant product version numbers
import oracledb
import sys
import platform

print("oracledb.__version__:", oracledb.__version__)
print("platform.platform:", platform.platform())
print("sys.maxsize > 2**32:", sys.maxsize > 2**32)
print("platform.python_version:", platform.python_version())
oracledb.__version__: 2.1.0
platform.platform: Windows-10-10.0.19044-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.11.5

mac-vtl avatar Mar 20 '24 10:03 mac-vtl

Yes, that would be possible and shouldn't be too much effort, either.

anthony-tuininga avatar Mar 20 '24 15:03 anthony-tuininga

I have added the function get_network_service_names() which does what you request. If you are able to build from source you can verify that it works for you, too.

anthony-tuininga avatar Mar 26 '24 16:03 anthony-tuininga

not currently setup to build from source but will try to get setup and provide feedback asap. thanks for the quick turnaround.

mac-vtl avatar Mar 26 '24 18:03 mac-vtl

I can confirm it works as expected. tyvm.

mac-vtl avatar Mar 27 '24 11:03 mac-vtl

This was included in version 2.2.0 which was just released.

anthony-tuininga avatar May 02 '24 16:05 anthony-tuininga