Skip to content

Commit

Permalink
Feature/oracledb plugin (ToolJet#2388)
Browse files Browse the repository at this point in the history
* oracledb initial commit
- Added oracledb package

* Implemented connection and operations

* Working on oracle db integration

* Implemented query & bulk operations

* Fixed initial client reintialization problem

* Added custom client library path option

* Added oracle client library installation steps to dev docker file

* Testing changed docker setup on cloud

* Testing heroku app.json

* Removed unwanted scripts from dockerfiles

* Updated field label

* update oracledb client lib for ec2

* update package-lock

* refactoring code

* Updated docs

* Resolved some lint errors

Co-authored-by: Akshay Sasidharan <akshaysasidharan93@gmail.com>
  • Loading branch information
shah21 and akshaysasidrn authored Mar 15, 2022
1 parent 930b4bf commit eaf9361
Show file tree
Hide file tree
Showing 22 changed files with 1,114 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Aptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# you can list packages
libaio1

# or include links to specific .deb files

# or add custom apt repos (only required if using packages outside of the standard Ubuntu APT repositories)
6 changes: 6 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
"buildpacks": [
{
"url": "heroku/nodejs"
},
{
"url": "heroku-community/apt"
},
{
"url": "https://github.com/featurist/oracle-client-buildpack.git"
}
],
"environments": {
Expand Down
14 changes: 14 additions & 0 deletions deploy/ec2/setup_machine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ sudo luarocks install lua-resty-auto-ssl
sudo mkdir /etc/resty-auto-ssl /var/log/openresty /etc/fallback-certs
sudo chown -R www-data:www-data /etc/resty-auto-ssl

# Oracle db client library setup
sudo apt install -y libaio1
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
unzip instantclient-basiclite.zip && \
sudo mv instantclient*/ /usr/lib/instantclient && \
rm instantclient-basiclite.zip && \
sudo ln -s /usr/lib/instantclient/libclntsh.so.19.1 /usr/lib/libclntsh.so && \
sudo ln -s /usr/lib/instantclient/libocci.so.19.1 /usr/lib/libocci.so && \
sudo ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
sudo ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2
export LD_LIBRARY_PATH="/usr/lib/instantclient"


# Gen fallback certs
sudo openssl rand -out /home/ubuntu/.rnd -hex 256
sudo chown www-data:www-data /home/ubuntu/.rnd
Expand Down Expand Up @@ -52,6 +65,7 @@ mv /tmp/setup_app ~/app/setup_app
sudo chmod +x ~/app/setup_app

sudo npm install -g npm@7.20.0
sudo chown -R 1000:1000 "/home/ubuntu/.npm"

# Building ToolJet app
sudo npm install -g @nestjs/cli
Expand Down
15 changes: 15 additions & 0 deletions docker/production.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ FROM node:14.17.3-alpine
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN apk add postgresql-client freetds

# Install Instantclient Basic Light Oracle and Dependencies
RUN apk --no-cache add libaio libnsl libc6-compat curl && \
cd /tmp && \
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
unzip instantclient-basiclite.zip && \
mv instantclient*/ /usr/lib/instantclient && \
rm instantclient-basiclite.zip && \
ln -s /usr/lib/instantclient/libclntsh.so.19.1 /usr/lib/libclntsh.so && \
ln -s /usr/lib/instantclient/libocci.so.19.1 /usr/lib/libocci.so && \
ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2

ENV LD_LIBRARY_PATH /usr/lib/instantclient

RUN mkdir -p /app

# copy npm scripts
Expand Down
14 changes: 14 additions & 0 deletions docker/server.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN apk add postgresql-client freetds

# Install Instantclient Basic Light Oracle and Dependencies
RUN apk --no-cache add libaio libnsl libc6-compat curl && \
cd /tmp && \
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
unzip instantclient-basiclite.zip && \
mv instantclient*/ /usr/lib/instantclient && \
rm instantclient-basiclite.zip && \
ln -s /usr/lib/instantclient/libclntsh.so.19.1 /usr/lib/libclntsh.so && \
ln -s /usr/lib/instantclient/libocci.so.19.1 /usr/lib/libocci.so && \
ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2

ENV LD_LIBRARY_PATH /usr/lib/instantclient

RUN mkdir -p /app

# copy npm scripts
Expand Down
16 changes: 15 additions & 1 deletion docker/server.Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# pull official base image
FROM node:14.17.3-alpine
RUN apk add postgresql-client freetds
RUN apk add postgresql-client

# Install Instantclient Basic Light Oracle and Dependencies
RUN apk --no-cache add libaio libnsl libc6-compat curl && \
cd /tmp && \
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
unzip instantclient-basiclite.zip && \
mv instantclient*/ /usr/lib/instantclient && \
rm instantclient-basiclite.zip && \
ln -s /usr/lib/instantclient/libclntsh.so.19.1 /usr/lib/libclntsh.so && \
ln -s /usr/lib/instantclient/libocci.so.19.1 /usr/lib/libocci.so && \
ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2

ENV LD_LIBRARY_PATH /usr/lib/instantclient

ENV NODE_ENV=development
ENV NODE_OPTIONS="--max-old-space-size=4096"
Expand Down
47 changes: 47 additions & 0 deletions docs/docs/data-sources/oracledb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

# Oracle DB

ToolJet can connect to Oracle databases to read and write data.

## Connection

A Oracle DB can be connected with the following credentails:
- **Host**
- **Port**
- **SID / Service Name** ( Database name must be a SID / Service Name )
- **Database Name**
- **SSL**
- **Username**
- **Password**
- **Client Library Path** ( Only need for local setup )

:::info
You can also test your connection before saving the configuration by clicking on `Test Connection` button.
:::

Click on **Test connection** button to verify if the credentials are correct and that the database is accessible to ToolJet server. Click on **Save** button to save the data source.

## Querying Oracle DB

Once you have added a Oracle DB data source, click on `+` button of the query manager to create a new query. There are two modes by which you can query SQL:

1. **[SQL mode](/docs/data-sources/oracledb#sql-mode)**
2. **[GUI mode](/docs/data-sources/oracledb#gui-mode)**

#### SQL mode

SQL mode can be used to write raw SQL queries. Select SQL mode from the dropdown and enter the SQL query in the editor. Click on the `run` button to run the query.

**NOTE**: Query should be saved before running.

#### GUI mode

GUI mode can be used to query Oracle database without writing queries. Select GUI mode from the dropdown and then choose the operation **Bulk update using primary key**. Enter the **Table** name and **Primary key column** name. Now, in the editor enter the records in the form of an array of objects.

**Example**: `{{ [ {id: 1, channel: 33}, {id:2, channel:24} ] }}`

Click on the **run** button to run the query. **NOTE**: Query should be saved before running.

:::tip
Query results can be transformed using transformations. Read our transformations documentation to see how: **[link](/docs/tutorial/transformations)**
:::
2 changes: 2 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions plugins/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@tooljet-plugins/mssql": "file:packages/mssql",
"@tooljet-plugins/mysql": "file:packages/mysql",
"@tooljet-plugins/n8n": "file:packages/n8n",
"@tooljet-plugins/oracledb": "file:packages/oracledb",
"@tooljet-plugins/postgresql": "file:packages/postgresql",
"@tooljet-plugins/redis": "file:packages/redis",
"@tooljet-plugins/restapi": "file:packages/restapi",
Expand Down
4 changes: 4 additions & 0 deletions plugins/packages/oracledb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
lib/*.d.*
lib/*.js
lib/*.js.map
4 changes: 4 additions & 0 deletions plugins/packages/oracledb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# Oracle DB

Documentation on: https://docs.tooljet.com/docs/data-sources/oracledb
7 changes: 7 additions & 0 deletions plugins/packages/oracledb/__tests_/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

// const oracledb = require('../lib');

describe('oracledb', () => {
it.todo('needs tests');
});
1 change: 1 addition & 0 deletions plugins/packages/oracledb/lib/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eaf9361

Please sign in to comment.