Giter Club home page Giter Club logo

kexasol's Introduction

Build Status Release

KExasol is a custom database driver for Exasol implemented in Kotlin (JVM).

It offers unique features compared to standard JDBC driver:

  • based on native WebSocket API;
  • takes advantage of modern I/O libraries: Okio, OkHttp, Moshi;
  • efficient data transport via CSV streaming;
  • read and write data in parallel processes with linear scaling;
  • network traffic compression;
  • rich SQL query formatting with named and typed placeholders;

KExasol encourages best practices that are specific for Exasol distributed architecture and massively parallel data processing. It will help you to fully leverage capabilities of this analytical DBMS.

Quick links

System requirements

  • Exasol >= 6.0
  • Kotlin >= 1.4
  • Java >= 8

Getting started

Add JitPack Maven repository to build.gradle.kts:

repositories {
    ...
    maven { setUrl("https://jitpack.io") }
}

Add dependency:

implementation("com.github.badoo:kexasol:0.2.1")

Run basic query:

val exa = ExaConnectionOptions(dsn = "<host:port>", user = "sys", password = "exasol").connect()

exa.use {
    val st = exa.execute("SELECT user_name, created FROM exa_all_users LIMIT 5")

    st.forEach { row ->
        println(row)
    }
}

Read data via CSV streaming:

val exa = ExaConnectionOptions(dsn = "<host:port>", user = "sys", password = "exasol").connect()

exa.use {
    exa.streamExportReader("EXA_ALL_USERS", columns = listOf("USER_NAME", "CREATED")) { reader ->
        reader.forEach { row ->
            println(row.getString("USER_NAME"))
            println(row.getLocalDateTime("CREATED"))
        }
    }
}

Create a new table and import some data in transaction:

val exa = ExaConnectionOptions(dsn = "<host:port>", user = "sys", password = "exasol").connect()

val cols = listOf("USER_ID", "USER_NAME", "IS_ACTIVE")

val data = listOf<List<Any?>>(
    listOf(1L, "Alice", true),
    listOf(2L, "Bob", false),
    listOf(3L, "Cindy", null),
)

exa.use {
    exa.setAutocommit(false)

    exa.execute("CREATE SCHEMA IF NOT EXISTS kexasol_test")

    exa.execute("""
        CREATE OR REPLACE TABLE test_table
        (
            user_id       DECIMAL(9,0),
            user_name     VARCHAR(255),
            is_active     BOOLEAN
        )
    """)

    val importSt = exa.streamImportIterator("test_table", cols, data.iterator())
    println("IMPORT affected rows: ${importSt.rowCount}")

    exa.commit()
}

Check other examples and best practices.

Created by

Vitaly Markov, 2020

Enjoy!

License

Copyright 2020 Badoo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

kexasol's People

Contributors

littlek0i avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kexasol's Issues

Change enum package name

Hello,

Currently trying the library from Java. I am getting this error,

as of release 5, 'enum' is a keyword, and may not be used as an identifier

Would it be possible to rename the enum package name? I think mode may fit as an replacement.

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.