Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions Framework/Built_In_Automation/Database/BuiltInFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions Framework/install_handler/database/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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
Expand All @@ -36,7 +36,7 @@ async def install():

if not is_already_installed:

module_name = 'cx_Oracle'
module_name = 'oracledb'

await send_response({
"action": "status",
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions Framework/install_handler/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading