Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hymkor/sqlbless
The Command-line Database Client
https://github.com/hymkor/sqlbless
command-line oracle postgresql sql sql-client
Last synced: 19 days ago
JSON representation
The Command-line Database Client
- Host: GitHub
- URL: https://github.com/hymkor/sqlbless
- Owner: hymkor
- License: mit
- Created: 2023-04-06T14:32:48.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-28T16:44:36.000Z (6 months ago)
- Last Synced: 2024-05-29T00:13:16.736Z (6 months ago)
- Topics: command-line, oracle, postgresql, sql, sql-client
- Language: Go
- Homepage:
- Size: 313 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SQL-Bless
===========**<English>** / [<Japanese>](./README_ja.md)
The SQL-Bless is a command-line database client like SQL\*Plus or psql.
- Emacs-like keybindings for inline editing of multiple lines of SQL.
- The action of `Enter` key will only insert a line feed code.
- Press `Ctrl-J` or `Ctrl`-`Enter` to execute the input.
- 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 `EDIT` command)
- Auto commit is disabled.![image](./demo.gif)
[Video](https://www.youtube.com/watch?v=_cxBQKpfUds) by [@emisjerry](https://github.com/emisjerry)
| Key | Binding |
|-----|---------|
| `Enter`, `Ctrl`-`M` | **Insert a linefeed** |
| `Ctrl`-`Enter`/`J` or `;`+`Enter`[^semicolon] | **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) |[^semicolon]: `;` or the string specfied with the option `-term string`
Supported commands
------------------- `SELECT` / `INSERT` / `UPDATE` / `DELETE`
- `INSERT`, `UPDATE` and `DELETE` begin the transaction automatically.
- `COMMIT` / `ROLLBACK`
- `SPOOL`
- `spool 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 comments`
- `DESC [tablename]` / `\D [tablename]`
- When the tablename is given, show the specification of the the table
- Without the tablename, show the list of tables.
- `HISTORY`
- Show the history of input SQLs
- `EDIT tablename [WHERE conditions...]`
- Start an [editor][csvi] to modify the selected records of the table.
- In the editor, these keys are bound.
- `x` or `d`: set NULL to the current cell
- `c`: apply changes
- `q` or `ESC`: quit without applying changes
- 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](https://github.com/hymkor/sqlbless/issues/new).- `;` (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 ignoredExample of a spooled file
--------------------------``` CSV
# (2023-04-17 22:52:16)
# select *
# from tab
# where rownum < 5
TNAME,TABTYPE,CLUSTERID
AQ$_INTERNET_AGENTS,TABLE,
AQ$_INTERNET_AGENT_PRIVS,TABLE,
AQ$_KEY_SHARD_MAP,TABLE,
AQ$_QUEUES,TABLE,
# (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](https://github.com/hymkor/sqlbless/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- The drivers used are https://github.com/glebarez/go-sqlite
### 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
### PostgreSQL
$ sqlbless postgres host=127.0.0.1 port=5555 user=USERNAME password=PASSWORD dbname=DBNAME sslmode=disable
$ sqlbless postgres postgres://USERNAME:[email protected]:5555/DBNAME?sslmode=verify-full
$ sqlbless postgres://USERNAME:[email protected]:5555/DBNAME?sslmode=verify-full- The driver used is https://github.com/lib/pq
### SQL Server
$ sqlbless sqlserver sqlserver://@localhost?database=master
$ sqlbless sqlserver://@localhost?database=master
( Windows authentication )- The driver used is https://github.com/microsoft/go-mssqldb
### MySQL
$ sqlbless.exe mysql user:password@/database
- The driver used is http://github.com/go-sql-driver/mysql
- The `?parseTime=true&loc=Local` parameter is preset, but it can be overriddenCommon Options
--------------- `-crlf`
- Use CRLF
- `-fs string`
- 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 `SELECT` and `EDIT`
- `-help`
- Help[csvi]: https://github.com/hymkor/csvi