diff --git a/Framework/Built_In_Automation/Database/BuiltInFunctions.py b/Framework/Built_In_Automation/Database/BuiltInFunctions.py index c5b74a03..1f75d32d 100755 --- a/Framework/Built_In_Automation/Database/BuiltInFunctions.py +++ b/Framework/Built_In_Automation/Database/BuiltInFunctions.py @@ -277,32 +277,29 @@ def db_get_connection(session_name): ) CommonUtil.ExecLog(sModuleInfo, "Connected to Snowflake.", 1) elif "oracle" in db_type: - import cx_Oracle - - # https://cx-oracle.readthedocs.io/en/latest/api_manual/module.html#cx_Oracle.makedsn - if db_sid != 'zeuz_failed': - dsn = cx_Oracle.makedsn( - host=db_host, - port=db_port, - sid=db_sid - ) - elif db_service_name != 'zeuz_failed': - dsn = cx_Oracle.makedsn( - host=db_host, - port=db_port, - service_name=db_service_name - ) + import oracledb + + # Construct the DSN (Data Source Name) using the Easy Connect syntax + dsn = None + if db_service_name and db_service_name != 'zeuz_failed': + # Use Service Name for connection: host:port/service_name + dsn = f"{db_host}:{db_port}/{db_service_name}" + elif db_sid and db_sid != 'zeuz_failed': + # Use SID for connection: host:port:sid + dsn = f"{db_host}:{db_port}:{db_sid}" else: - CommonUtil.ExecLog(sModuleInfo, "Either db_sid or db_service must be provide.", 3) + CommonUtil.ExecLog(sModuleInfo, "Either db_sid or db_service must be provided.", 3) return "zeuz_failed" + + CommonUtil.ExecLog(sModuleInfo, f"Attempting Oracle connection using DSN: {dsn}", 1) # Connect to db - # https://cx-oracle.readthedocs.io/en/latest/api_manual/module.html#cx_Oracle.connect - db_con = cx_Oracle.connect( + db_con = oracledb.connect( user=db_user_id, password=db_password, dsn=dsn, ) + CommonUtil.ExecLog(sModuleInfo, "Connected to Oracle using python-oracledb.", 1) else: import pyodbc diff --git a/Framework/install_handler/database/oracle.py b/Framework/install_handler/database/oracle.py index 848e46c3..70c63d56 100644 --- a/Framework/install_handler/database/oracle.py +++ b/Framework/install_handler/database/oracle.py @@ -4,9 +4,9 @@ tools = InstallerTools() async def check_status(): - """Checks if cx_Oracle Python library is installed.""" + """Checks if oracledb Python library is installed.""" - if await tools.check_python_module_available("cx_Oracle"): + if await tools.check_python_module_available("oracledb"): await send_response({ "action": "status", "data": { @@ -24,7 +24,7 @@ async def check_status(): "category": "Database", "name": "Oracle", "status": "not installed", - "comment": "Install cx_Oracle to connect to Oracle databases.", + "comment": "Install oracledb to connect to Oracle databases.", } }) return False @@ -36,7 +36,7 @@ async def install(): if not is_already_installed: - module_name = 'cx_Oracle' + module_name = 'oracledb' await send_response({ "action": "status", @@ -50,7 +50,7 @@ async def install(): # NOTE: cx_Oracle is deprecated and gives install error on Windows if module_name == "cx_Oracle": - tools.logger.warning("cx_Oracle is deprecated, recommended to use python-oracledb instead.") + tools.logger.warning("cx_Oracle is deprecated, recommended to use oracledb instead.") install_oracle, msg = await tools.add_python_package(module_name) if install_oracle: diff --git a/Framework/install_handler/route.py b/Framework/install_handler/route.py index 16cc9903..eaff0e9a 100644 --- a/Framework/install_handler/route.py +++ b/Framework/install_handler/route.py @@ -175,8 +175,7 @@ "status": "none", "comment": "Oracle driver is required to connect to Oracle database.", "install_text": "install", - # "os": ["windows", "linux", "darwin"], - "os": ["linux", "darwin"], # TODO: add windows after migrating to python-oracledb + "os": ["windows", "linux", "darwin"], "status_function": oracle.check_status, "install_function": oracle.install, "user_password": "no"