Solutions

Oracle DB API Wrapper

8min

Overview

Document image


Note

Currently this solution only supports SELECT functions, and currently does not support INSERT, UPDATE, JOIN, DELETE

Requirements

A Litmus Edge is setup. An Oracle DB is accessible through the network.

How to use the solution using Docker

  • After Checkout, a tar.gz file is expected to be downloaded
  • Log in to your LitmusEdge, Navigate to Applications -> Images
  • Click on ([27-icon icon="fa fa-plus"]) Upload Image and upload the tar file there
  • Once uploaded successfully, Navigate to Applications -> Containers and enter the docker run command

Here is an example to run Oracle DB API Wrapper with Docker :

docker run -dt --name oracle-gateway -p <HOST_PORT>:3000 \ -e LOG_LEVEL='<LOG_LEVEL>' \ -e LOG_MAX_SIZE='<LOG_MAX_SIZE>' \ -e LOG_MAX_FILES='<LOG_MAX_FILES>' \ --restart=always \ oracle-gateway:latest

 Configuration Options

⚠️ When using Docker, the following environment variables must be set before running the container.

Key

Description

-dt

Run the containers in detached mode and with Terminal.

-- name oracle-gateway

Assign a name to the container (optional)

-p <HOST_PORT>:3000

Map a host port to port 3000 of the container (required)

-e LOG_LEVEL='<LOG_LEVEL>'

Set the log level for the application (optional, defaults to 'info').

-e LOG_MAX_SIZE='<LOG_MAX_SIZE>'

Set the maximum size for log files (optional, defaults to '20m').

-e LOG_MAX_FILES='<LOG_MAX_FILES>'

Set the maximum number of files for log rotation (optional, defaults to '14d').

--restart=always

Automatically restart the container if it exits unexpectedly.

oracle-gateway:latest

Docker Image tag and version

Example Request Body used in Flows

{ "queryStr" : "SELECT 1 FROM Dual", "user": "sys", "password": "Litmus@1", "mode": "THN", "privilege": true, "connString": "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='<server>')(PORT='1521'))(CONNECT_DATA=(SERVER='<server>')(SERVICE_NAME='XE')))", "server": "<server>", "port": 1521, "hostname": "<server>", "SID": "XE", "serviceName": "XE"}

Method

URL

Description

Extras

POST

/api/data









Parameters in body







mode

One of the following: ("CNS","SRN","SID","THK","THN")





-> CNS Connection String

(default)





Parameters

user, password, connString, queryStr





-> SRN Service Name







Parameters

user, password, hostname, port, serviceName, queryStr





-> SID Session ID







Parameters

user, password, hostname, port, SID, queryStr





-> THK Thick Mode using ORACLE Client Connection







Parameters

user, password, connString, queryStr





-> THN Thin Mode using ORACLE Client Connection







Parameters

user, password, connString, queryStr

Example LE Flow template

[{"id":"97267f2fe9d4fbff","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"a38cf2acef421496","type":"inject","z":"97267f2fe9d4fbff","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":100,"wires":[["78413ace9929c3c1"]]},{"id":"14ea163dcb02d5dc","type":"debug","z":"97267f2fe9d4fbff","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1010,"y":220,"wires":[]},{"id":"d90a39d5f7159c9d","type":"http request","z":"97267f2fe9d4fbff","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":690,"y":160,"wires":[["f598318fe565075f"]]},{"id":"78413ace9929c3c1","type":"function","z":"97267f2fe9d4fbff","name":"Set connection parameters","func":"const ip = '<IP_CONTAINER>:<MAPED_PORT>';\n\nmsg.method ='post';\nmsg.url = http://${ip}/api/data;\nmsg.headers={\n 'Content-Type' : 'application/json'\n}\n\n//mode (CNS,SRN,SID,THK,THN)\n\nmsg.payload = { \n queryStr : "", \n user: "", \n password: "", \n mode: "", \n privilege: true, \n connString: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='<SERVER>')(PORT='1521'))(CONNECT_DATA=(SERVER='<SERVER>')(SERVICE_NAME='<SERVICE_NAME>'))), \n server: "", \n port: 1521, \n hostname: "", \n SID: "", \n serviceName: "<SERVICE_NAME>"}\n\nmsg.redirect= "follow"\n\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":160,"wires":[["d90a39d5f7159c9d"]]},{"id":"f598318fe565075f","type":"json","z":"97267f2fe9d4fbff","name":"","property":"payload","action":"","pretty":false,"x":850,"y":220,"wires":[["14ea163dcb02d5dc"]]}]

Example LE Flow

[ { "id": "01740c8932692cc4", "type": "tab", "label": "Flow 1", "disabled": false, "info": "", "env": [] }, { "id": "e6cf2c52c4ec85dd", "type": "inject", "z": "01740c8932692cc4", "name": "", "props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 220, "y": 100, "wires": [["57137f9e.ce895"]] }, { "id": "94b070f38334a607", "type": "debug", "z": "01740c8932692cc4", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1010, "y": 220, "wires": [] }, { "id": "3eb9c0257dda01e3", "type": "http request", "z": "01740c8932692cc4", "name": "", "method": "use", "ret": "txt", "paytoqs": "ignore", "url": "", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "x": 690, "y": 160, "wires": [["1ef3217515dd667e"]] }, { "id": "57137f9e.ce895", "type": "function", "z": "01740c8932692cc4", "name": "Set connection parameters", "func": "const ip = '10.30.50.3:3000';\n\nmsg.method ='post';\nmsg.url = `http://${ip}/api/data`;\nmsg.headers={\n 'Content-Type' : 'application/json'\n}\n\nmsg.payload = {\n queryStr : \"SELECT 1 FROM Dual\",\n user: \"sys\",\n password: \"Litmus@1\",\n mode: \"THN\",\n privilege: true,\n connString: `(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='${ip}')(PORT='1521'))(CONNECT_DATA=(SERVER='${ip}')(SERVICE_NAME='XE')))`,\n}\n\nmsg.redirect= \"follow\"\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 440, "y": 160, "wires": [["3eb9c0257dda01e3"]] }, { "id": "1ef3217515dd667e", "type": "json", "z": "01740c8932692cc4", "name": "", "property": "payload", "action": "", "pretty": false, "x": 850, "y": 220, "wires": [["94b070f38334a607"]] }]