python-oracledb
python-oracledb copied to clipboard
Expose service names available in tnsnames.ora
- 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?
- 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
Yes, that would be possible and shouldn't be too much effort, either.
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.
not currently setup to build from source but will try to get setup and provide feedback asap. thanks for the quick turnaround.
I can confirm it works as expected. tyvm.
This was included in version 2.2.0 which was just released.