Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
926 B
3
Indexable
Never
else:
    _, _, schema_target, user_target, password_target, host_target, port_target = connect_to_database(json_data, replicationTarget_EXT)

    oracle_dsn = f"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={host_target})(PORT={port_target})))(CONNECT_DATA=(SERVICE_NAME={schema_target})(SID={sid})))"  # Add SID here
    dsn_kwargs = {
        'user': user_target,
        'password': password_target,
        'dsn': oracle_dsn,
        'encoding': 'UTF-8',
    }

    try:
        import cx_Oracle
        target_connection = cx_Oracle.connect(**dsn_kwargs)
        target_cursor = target_connection.cursor()
    except ImportError:
        logging.error("cx_Oracle library not found. Make sure it's installed to establish Oracle connections.")
        raise
    except cx_Oracle.DatabaseError as ex:
        logging.error(f"Error while connecting to Oracle database: {ex}")
        raise

# Rest of your code...