SQL-Bless
<English> / <Japanese>
SQL-Bless is a command-line database client similar to SQL*Plus, supporting multiple database systems.
It was designed with reliability and transparency in mind. In the past, I had to deliver an unfinished system due to client pressure, which led to serious data inconsistencies that took enormous effort to fix. That experience made me realize how important it is to have a tool that prevents silent data corruption and keeps a complete, traceable log of every operation. SQL-Bless is the result of that lesson — a tool that values safety over convenience.
- Emacs-like keybindings for editing multi-line SQL input.
- Pressing Enter inserts a line break by default.
- Use the ↑ (Up) arrow key or Ctrl-P to move the cursor to the previous line for editing.
- Press Ctrl-J or Ctrl-Enter to execute the input immediately.
- When you press Enter alone, the input is also executed if the last line ends with a semicolon or if the first word is a non-SQL command such as
EXITorQUIT.
- Save the result of SELECT in CSV format
- Supported RDBMS
- SQLite3
- Oracle
- PostgreSQL
- Microsoft SQL Server
- MySQL
- Allows editing database records directly, similar to a spreadsheet (with the
EDITcommand) - Transaction mode (auto-commit disabled)
- A transaction is automatically started when executing DML (INSERT/UPDATE/DELETE)
- Users cannot input a BEGIN statement (transactions are managed automatically)
- Transactions can be ended with COMMIT or ROLLBACK
- Whether DDL (CREATE/ALTER/DROP etc.) can be executed inside a transaction depends on the database:
- PostgreSQL: All DDL can be executed inside a transaction except VACUUM, REINDEX, CLUSTER, CREATE/DROP DATABASE, and CREATE/DROP TABLESPACE
- SQLite3: All DDL can be executed inside a transaction except VACUUM
- Oracle / SQL Server / MySQL: DDL must be executed after ending the transaction with COMMIT or ROLLBACK
- If a transaction is still active when executing DDL, a warning will be displayed
- Table name and column name completion
- Column name completion works only when the corresponding table name appears to the left of the cursor

Video by @emisjerry
| Key | Binding |
|---|---|
Enter, Ctrl-M |
Insert a newline (or execute SQL if line ends with ; or is a short command1) |
Ctrl-Enter/J |
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
SELECT/INSERT/UPDATE/DELETE/MERGE...;INSERT,UPDATE,DELETE, andMERGEautomatically start a transaction.- For these commands, input continues across lines until a semicolon (
;) or the string specified with the-termoption is entered.
COMMITROLLBACK;-- semicolon requiredSAVEPOINT savepoint;
(orSAVE TRANSACTION savepoint;for Microsoft SQL Server)ROLLBACK TO savepoint;
(orROLLBACK TRANSACTION savepoint;for Microsoft SQL Server)SPOOLspool FILENAME.. open FILENAME and write log and output.spool off.. stop spooling and close.
EXIT/QUIT- Rollback a transaction and exit SQL-Bless.
START filename- Start the SQL script given with filename
REM commentsDESC [tablename]/\D [tablename]- When a table name is specified, shows the schema of that table.
- If omitted, displays a list of tables.
- In the table list view, the following keys are available:
r: Open theEDITcommand for the selected table.Enter: Show the schema of the selected table.
HISTORY- Show the history of input SQLs
EDIT [tablename [WHERE conditions...]]- Start an editor to modify the selected records of the table.
- In the editor, these keys are bound.
xord: set NULL to the current cellESC+y: Apply changes and exitESC+n: Discard changes and exitq: Now equivalent toESCc: Apply changes and exit (deprecated)
- Because the EDIT statement automatically generates SQL from data changed in the editor, it may not be able to properly represent SQL data for special types specific to individual databases. If you find it, we would appreciate it if you could contact us.
HOST command-line- Executes an operating system command.
;(or the string specified with-term string) is a statement seperator when script is executed- When sql is input interactively, terminator string (
;or the string specified with-term string) is ignored
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
Configuration
SQL-Bless does not rely on any external configuration files. All settings—including database connection parameters, output format, and other options—are specified directly via command-line arguments.
For convenience, you can wrap frequently used connection settings in a shell script or batch file. Sample scripts for various databases are provided in this repository (see run-*.cmd). This approach ensures predictable, repeatable startup behavior without relying on hidden configuration files.
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
- The drivers used are https://github.com/glebarez/go-sqlite
- Example startup batch file
Oracle
$ sqlbless oracle oracle://USERNAME:PASSWORD@HOSTNAME:PORT/SERVICE
$ sqlbless oracle://USERNAME:PASSWORD@HOSTNAME:PORT/SERVICE
- The driver used is https://github.com/sijms/go-ora
- Example startup batch file
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
- The driver used is https://github.com/lib/pq
- Example startup batch file
SQL Server
$ sqlbless sqlserver sqlserver://@localhost?database=master
( Windows authentication )
$ sqlbless sqlserver "Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;protocol=lpc"
- The driver used is https://github.com/microsoft/go-mssqldb
- Example startup batch file
MySQL
$ sqlbless.exe mysql user:password@/database
- The driver used is http://github.com/go-sql-driver/mysql
- The
?parseTime=true&loc=Localparameter is preset, but it can be overridden - Example startup batch file
Common Options
-crlf- Use CRLF
-fs string- Set a field separator (default:
",")
- Set a field separator (default:
-null string- Set a string representing NULL (default: ␀)
-tsv- Use TAB as seperator
-f string- Start the script
-submit-enter- Submit by [Enter] and insert a new line by [Ctrl]-[Enter]
-debug- Print type-information in the header of
SELECTandEDIT
- Print type-information in the header of
-spool filename- Spool to filename from startup
-help- Help
-rv- Use color schemes designed for light (white) backgrounds.
Environment Variables
NO_COLOR- If defined and non-empty, suppress all color output.
- If undefined, colors are displayed as usual.
- (Follows https://no-color.org/)
RUNEWIDTH_EASTASIAN"1"— Treat ambiguous-width Unicode characters as double-width (2 cells).- Any other non-empty value — Treat them as single-width (1 cell).
COLORFGBG- When defined in the form
(FG);(BG), where(FG)and(BG)are integers representing the foreground and background colors respectively, and(FG)is less than(BG), CSVI assumes a light background and uses colors suitable for it (equivalent to-rv).
- When defined in the form
Acknowledgements
Author
License
MIT License
-
DESC,EDIT,EXIT,HISTORY,HOST,QUIT,REM,SPOOL,START,\D↩︎