SQL-Bless

<English> / <Japanese>

The SQL-Bless is a command-line database client like SQL*Plus or psql.

image

Video by @emisjerry

Key Binding
Enter, Ctrl-M Insert a linefeed
Ctrl-Enter/J or ;+Enter2 Execute SQL
Ctrl-F/B Move Cursor forward or backward
Ctrl-N/P Move Cursor or refer history
Ctrl-C Exit with rollback
Ctrl-D Delete character or submit EOF (exit with rollback)
ALT-P, Ctrl-Up, PageUp Insert the previous SQL (history)
ALT-N, Ctrl-Down, PageDown Insert the next SQL (history)
TAB Table name and column name completion

Supported commands

Example of a spooled file

# (2023-04-17 22:52:16)
# select *
#   from tab
#  where rownum < 5
TNAME,TABTYPE,CLUSTERID
AQ$_INTERNET_AGENTS,TABLE,<NULL>
AQ$_INTERNET_AGENT_PRIVS,TABLE,<NULL>
AQ$_KEY_SHARD_MAP,TABLE,<NULL>
AQ$_QUEUES,TABLE,<NULL>
# (2023-04-17 22:52:20)
# history
0,2023-04-17 22:52:05,spool hoge
1,2023-04-17 22:52:16,"select *
  from tab
 where rownum < 5"
2,2023-04-17 22:52:20,history

Install

Download the binary package from Releases and extract the executable.

via Scoop-installer (Windows)

scoop install https://raw.githubusercontent.com/hymkor/sqlbless/master/sqlbless.json

or

scoop bucket add hymkor https://github.com/hymkor/scoop-bucket
scoop install sqlbless

Installing via Go

go install github.com/hymkor/sqlbless/cmd/sqlbless@latest

How to start

$ sqlbless {options} [DRIVERNAME] DATASOURCENAME

DRIVERNAME can be omitted when DATASOURCENAME contains DRIVERNAME.

SQLite3

$ sqlbless sqlite3 :memory:
$ sqlbless sqlite3 path/to/file.db

Oracle

$ sqlbless oracle oracle://USERNAME:PASSWORD@HOSTNAME:PORT/SERVICE
$ sqlbless oracle://USERNAME:PASSWORD@HOSTNAME:PORT/SERVICE

PostgreSQL

$ sqlbless postgres host=127.0.0.1 port=5555 user=USERNAME password=PASSWORD dbname=DBNAME sslmode=disable
$ sqlbless postgres postgres://USERNAME:PASSWORD@127.0.0.1:5555/DBNAME?sslmode=verify-full
$ sqlbless postgres://USERNAME:PASSWORD@127.0.0.1:5555/DBNAME?sslmode=verify-full

SQL Server

$ sqlbless sqlserver sqlserver://@localhost?database=master

( Windows authentication )

$ sqlbless sqlserver "Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;protocol=lpc"

MySQL

$ sqlbless.exe mysql user:password@/database

Common Options

Acknowledgements

Author

hymkor (HAYAMA Kaoru)

License

MIT License


  1. Starting with v0.21, typing only EXIT or QUIT also terminates the input. ↩︎

  2. ; or the string specfied with the option -term string ↩︎