Skip to content

Shell for issuing SQL to relational databases via JDBC

License

Notifications You must be signed in to change notification settings

prodonjs/sqlline

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.3.0 org.hsqldb:hsqldb:2.4.0 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

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.3.0</version>
</dependency>

Building

Prerequisites:

  • Maven 3.2.1 or higher
  • Java 1.6 or higher (9 preferred)

Check out and build:

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

Authors

More information

About

Shell for issuing SQL to relational databases via JDBC

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.8%
  • Other 0.2%