Giter Club home page Giter Club logo

core-grpc-jdbc-connector's Introduction

Example JDBC gRPC Connector

CircleCI

This connector exemplifies how a JDBC gRPC Connector can be written. It contains examples that includes a MySQL Database, a PostgreSQL Database, a QIX Engine and the JDBC gRPC connector.

Run examples

Go to the examples folder and run the following:

ACCEPT_EULA=<yes/no> docker-compose up --build -d

Then follow the instructions for either corectl or node.

Node

Head into /examples/node and install the dependencies and then run the script index.js using the following commands:

npm install
npm start

To run integration tests you can use:

npm test

Corectl

To run the corectl example head into /examples/corectl. If you do not yet have corectl installed just follow the download instructions from corectl.

Once installed you can build using either the postgres or mysql database with the following commands, respectively:

corectl build --script mysql.qvs
corectl build --script postgres.qvs 

Take a peek at corectl.yml to see how the connections are set up for corectl. To view the tables you can then simply type:

corectl get tables

Performance tips

The perfomance of the JDBC gRPC connector can be tweaked with a few different environment settings.

You can use the DATABASE_FETCH_SIZE command to limit the memory consumption in the connector when fetching data from the database. DATABASE_FETCH_SIZE sets the amount of rows fetched from the database loaded into memory in batches. The default DATABASE_FETCH_SIZE is 100000. If DATABASE_FETCH_SIZE is not set, the entire database query is loaded into the memory of the connector.

You can use the MAX_DATA_CHUNK_SIZE command to tweak the size of the data chunks sent over gRPC to QIX Engine. The MAX_DATA_CHUNK_SIZE represents how many fields can be batched together in one package. This setting is highly dependant on the content of the fields and the package should be keept below the default 4MB gRPC package size limit. The default MAX_DATA_CHUNK_SIZE is set to 300

These settings can be changed in the example in docker-compose.yml file.

Run locally

Requirements

  • Java JDK 8.0
  • Maven 3.3.9
mvn install
java -jar ./target/core-grpc-jdbc-connector.jar

Add other JDBC Drivers

Other JDBC Drivers can be added to the pom.xml file in the following section:

<dependencies>
  <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.2</version>
  </dependency>
</dependencies>

Make sure you start your Qlik Associative Engine with the proper gRPC connector string to enable your JDBC driver. See an example here.

Athena driver

Installing driver

The AWS Athena driver is not officially deployed on a Maven repository, so you have to download the jar file and place it in the connector project manually.

You can download the driver here.

pom.xml entry:

<dependency>
    <groupId>com.amazonaws.athena.jdbc</groupId>
    <artifactId>jdbcdriver</artifactId>
    <version>2.0.5</version>
</dependency>

Put the following lines in your Dockerfile before the RUN mvn install command:

COPY AthenaJDBC42_2.0.5.jar /usr/src/app
RUN mvn install:install-file -Dfile=/usr/src/app/AthenaJDBC42_2.0.5.jar -DgroupId=com.amazonaws.athena.jdbc -DartifactId=jdbcdriver -Dversion=2.0.5 -Dpackaging=jar

Example configuration

Connection string:

{
  qType: 'jdbc',
  qName: 'jdbc',
  qConnectionString: 'CUSTOM CONNECT TO "provider=jdbc;driver=awsathena;AwsRegion=eu-central-1;S3OutputLocation=s3://aws-athena-query-results-athenatest1-eu-central-1"',
  qUserName: 'AWS Key',
  qPassword: 'AWS Token',
}

LOAD statement:

sql SELECT * FROM yourathendatabase.yourathenatable;

License

This repository is licensed under MIT but components used in the Dockerfile examples are under other licenses. Make sure that you are complying with those licenses when using the built images.

core-grpc-jdbc-connector's People

Contributors

renovate[bot] avatar dependabot[bot] avatar qlikossbuild avatar stefanenberg avatar wennmo avatar peol avatar carlioth avatar sublibra avatar donthomaso avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.