Code Monkey home page Code Monkey logo

sx8000's Introduction

sx8000

Build Status

sx8000 is a command-line tool for executing SQL queries, and exporting the query results to CSV files. This tool is written in pure-Java and utilizes standard JDBC APIs. The name sx8000 comes from the belief that this is probably about the 8000th tool implemented which does something similar. (kudos to pg8000)

  • Utilizes Java's standard JDBC API, requiring no additional installations other then the Java Runtime Environment.
  • JDBC libraries can be added/swapped/removed on the fly.
  • Configurable via launch arguments. No configuration files nor environment variables are required.
  • Query can either be supplied as a one-liner command line argument, or from a text file.
  • Automatic/configurable escaping of the CSV column values.
  • Automatic/configurable output file compression from the filename. (.deflate / .gzip / .bz2)
  • Automatic/configurable checksum file generation. (cf: example.csv.gz.sha256)

Usage

Prerequisites

  • JRE 8 or later.
  • JDBC driver library. (Derby / H2 / HSQLDB / PostgreSQL / MySQL drivers are included in the archive.)

Displaying Usage

Download or build the archive file. Move into the archive's root directory and execute the launch script.

unzip sx8000-${VERSION}.zip

cd sx-8000-${VERSION}

sh bin/sx8000

Usage summary will be displayed to the standard output when the script is launched with zero arguments. Specify at least one of the parameters to actually execute the tool.

sh bin/sx8000 --out "./foo.csv.gz" --statement "select now()" 

sh bin/sx8000 --out "./bar.csv.gz" --statement "filepath:path/to/hoge.sql" --checksum "false" 

Customizing JDBC Drivers

JDBC driver libraries can be added/changed/removed on the fly. The JDBC driver files can be found inin ./lib directory of the unzipped archive. Modify the jar files in this directory and adjust the CLASSPATH variable in the launch scripts. Older version of the JDBC drivers may require explicitly specifying the driver class name.

sh bin/sx8000 --driver "org.h2.Driver" --url "jdbc:h2:mem:" --out "./hello.csv.gz" --statement "select 'Hello World!' as Greeting"

Building from Source

Prerequisites

  • JDK 8 or later.
  • Internet access for downloading the dependencies from Maven central repository.

Build

Clone the repository, and execute gradlew clean build command. Archive files will be generated under ./build/distributions/ upon a successful build.

Disclaimer

sx8000 is not...

  • a GUI application.
  • a scheduler. Use crontab or other scheduling middleware for automation.
  • secured nor protected. Arbitrary query (cf: drop table ...;) can be executed without any validation.
  • for everyone. Think twice and use at your own risk.

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.