GithubHelp home page GithubHelp logo

swaroopak / sqlline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from julianhyde/sqlline

0.0 2.0 0.0 1.57 MB

Shell for issuing SQL to relational databases via JDBC

License: BSD 3-Clause "New" or "Revised" License

Shell 0.03% Batchfile 0.03% Java 99.94%

sqlline's Introduction

Build Status

Command-line shell for issuing SQL to relational databases via JDBC.

History

A fork of Marc Prud'hommeaux's sqlline project, also incorporating changes made by the LucidDB project, now modernized, mavenized and forkable in github. See also release history.

License and distribution

SQLLine is distributed under the 3-clause BSD License, meaning that you are free to redistribute, modify, or sell it with almost no restrictions.

It is distributed via the Maven Central Repository.

Quick start

If you have Coursier installed, you can quickly connect to a demo Hypersonic database with:

$ coursier launch sqlline:sqlline:1.6.0 org.hsqldb:hsqldb:2.4.1 net.hydromatic:foodmart-data-hsqldb:0.4 -M sqlline.SqlLine -- -u jdbc:hsqldb:res:foodmart -n FOODMART -p FOODMART -d org.hsqldb.jdbcDriver
0: jdbc:hsqldb:res:foodmart> select avg("shelf_height" * "shelf_width" * "shelf_depth") as "avg_volume" from "product";
+-------------------------+
|       avg_volume        |
+-------------------------+
| 2147.3845245442353      |
+-------------------------+
1 row selected (0.01 seconds)
0: jdbc:hsqldb:res:foodmart> !quit

Getting started

Copy the sqlline script (or sqlline.bat for Windows), sqlline-VERSION-jar-with-dependencies.jar and a JDBC driver jar into the same directory. (Or just put sqlline on your PATH.)

$ sqlline -d com.mysql.jdbc.Driver
sqlline> !connect jdbc:mysql://localhost:3306/scott user password
sqlline> !tables
+------------+--------------+-------------+---------------+----------+
| TABLE_CAT  | TABLE_SCHEM  | TABLE_NAME  |  TABLE_TYPE   | REMARKS  |
+------------+--------------+-------------+---------------+----------+
| null       | SCOTT        | BONUS       | TABLE         | null     |
| null       | SCOTT        | DEPT        | TABLE         | null     |
| null       | SCOTT        | EMP         | TABLE         | null     |
| null       | SCOTT        | SALGRADE    | TABLE         | null     |
| null       | metadata     | COLUMNS     | SYSTEM_TABLE  | null     |
| null       | metadata     | TABLES      | SYSTEM_TABLE  | null     |
+------------+--------------+-------------+---------------+----------+
sqlline> SELECT 1 + 2 AS c;
+---+
| C |
+---+
| 3 |
+---+
sqlline> !quit

To get help:

$ sqlline --help

If you prefer, you can invoke Java directly, without using the sqlline script:

$ java -jar sqlline-VERSION-jar-with-dependencies.jar --help

Connecting using URLs

A URL (or connect string) is a string that specifies the location of your database, and perhaps credentials and other parameters specific to your database's JDBC driver. It always starts with 'jdbc:', usually followed by the machine name of the database and additional parameters.

For example, the following bash command connects to Apache Drill, assuming that Drill is installed in /opt/apache-drill-1.15.0:

$ /opt/apache-drill-1.15.0/bin/sqlline -u "jdbc:drill:drillbit=example.com;auth=kerberos"

Because ';' is a command separator in bash, the URL is included in double-quotes ('"'). You will need to quote the URL and other arguments if they contain characters that are special in your shell; different shells have different special characters, but space ('ย '), dollar ('$'), single-quote ('''), bang ('!') and percent ('%') are some common examples.

Read the manual.

Maven Usage

Use the following definition to use sqlline in your maven project:

<dependency>
  <groupId>sqlline</groupId>
  <artifactId>sqlline</artifactId>
  <version>1.6.0</version>
</dependency>

Building

Prerequisites:

  • Maven 3.2.5 or higher
  • Java 8 or higher (10 preferred)

Check out and build:

git clone git://github.com/julianhyde/sqlline.git
cd sqlline
mvn package

Committers

More information

sqlline's People

Contributors

adityakishore avatar arina-ielchiieva avatar bdumon avatar bpoweski avatar joeposner avatar jongyeol avatar julianhyde avatar kminder avatar liancheng avatar marcprux avatar mmattozzi avatar parthchandra avatar prodonjs avatar rkoshy avatar sachini avatar slankka avatar snuyanzin avatar teroz avatar

Watchers

 avatar  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.