oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
307 stars 59 forks source link

dsn.py small fix to support NNE #307

Closed evgeniy-ginzburg-db closed 1 month ago

evgeniy-ginzburg-db commented 3 months ago

This is a couple of changes to fix DSN creation issue I have right now. In general, full support of tsnames.ora parameters in spec will be preferable, but currently I don't have resources to do it.

BR, Evgeniy

index eb4935d..198668d 100644
--- a/src/oracledb/dsn.py
+++ b/src/oracledb/dsn.py
@@ -47,8 +47,6 @@ def makedsn(
     port: int,
     sid: str = None,
     service_name: str = None,
-    dedicated: bool = False,
-    ssl: bool = False,
     region: str = None,
     sharding_key: str = None,
     super_sharding_key: str = None,
@@ -58,13 +56,8 @@ def makedsn(
     string is identical to the strings that are defined in the tnsnames.ora
     file.
     """
-    proto = 'TCP'
     connect_data_parts = []
     _check_arg("host", host)
-    if ssl:
-        proto = 'TCPS'
-    if dedicated:
-        connect_data_parts.append('(SERVER=DEDICATED)')
     if sid is not None:
         _check_arg("sid", sid)
         connect_data_parts.append(f"(SID={sid})")
@@ -82,6 +75,6 @@ def makedsn(
         connect_data_parts.append(f"(SUPER_SHARDING_KEY={super_sharding_key})")
     connect_data = "".join(connect_data_parts)
     return (
-        f"(DESCRIPTION=(ADDRESS=(PROTOCOL={proto})(HOST={host})"
+        f"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={host})"
         f"(PORT={port}))(CONNECT_DATA={connect_data}))"
     )
anthony-tuininga commented 3 months ago

The makedsn() method was added to python-oracledb solely for backwards compatibility with cx_Oracle. python-oracledb already has a much more capable method in the ConnectParams class. That covers all of the ones you are asking for and a lot more besides! These include server_type and protocol. Note that you can also pass all of these directly to the connect, connect_async, create_pool and create_pool_async methods. The ConnectParams class is for cases where you want to pass the parameters to multiple connections or you want to control things a bit more closely.

anthony-tuininga commented 1 month ago

I am assuming that the answer I gave in March covers the enhancement request and will close this.