Quantcast
Channel: 簡睿隨筆
Viewing all articles
Browse latest Browse all 897

命令行資料庫工具 SQL-Bless 與 CSV文字檔編輯 CSVI

$
0
0

介紹兩個命令行工具:SQL-Bless與CSVI,二者皆使用Go語言撰寫,不須安裝,直接執行執行檔即可。

  • SQL-Bless:SQL客戶端的命令行工具,能操作4種資料庫系統:Oracle、PostgreSQL、SQL Server與MySQL
  • CSVI:讀寫CSV檔案的命令行工具

1. SQL-Bless

[!tip] 連線語法
sqlbless 資料庫類型 "連線字串"
例如:

  • sqlbless sqlserver "sqlserver://@localhost?database=master"
  • sqlbless sqlserver "sqlserver://帳號:密碼@10.1.1.1?database=YOUR_DB&encrypt=disable"

支援的資料庫系統:

  • Oracle
  • PostgreSQL
  • SQL Server
  • MySQL

[!warning] 連線時發生TLS錯誤
連線時若出現"TLS Handshake failed: tls: server selected unsupported protocol version 301"訊息而無法連線時,可在連線最後面加上&encrypt=disable

1.1. SQL命令

  • SELECT / INSERT / UPDATE / DELETE
  • COMMIT / ROLLBACK
  • SPOOL
  • EXIT; / QUIT;
  • START SQL-script-filename
  • REM comments
  • Statement separator: ;

gh|700

1.2. 按鍵

Key Binding
Enter, Ctrl+M Insert a linefeed
Ctrl+Enter/J Execute text as SQL
Ctrl+F/B/N/P Editing like Emacs
Ctrl+C Exit with rollback
Ctr+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)
Ctrl+A, 0 Beginning of record
Ctrl+E, $ End of record
Ctrl+K Delete after cursor
Ctrl+U Delete before cursor
< First record
> End of last record
/ Search forward
? Search backward
n Search next
N Search next reverse

1.3. 批次檔快速連接

@echo off
if "%1"=="" goto USAGE
if "%1"=="master" goto MASTER
if "%1"=="msdb" goto MSDB
if "%1"=="temp" goto TEMP
goto END

:MASTER
sqlbless sqlserver "sqlserver://userid:password@10.1.1.1?database=MASTER"
goto END

:MSDB
sqlbless sqlserver "sqlserver://userid:password=1@10.1.1.1?database=MSDB"
goto END

:TEMP
sqlbless sqlserver "sqlserver://userid:password=1@10.1.1.1?database=TEMPDB"
goto END

:USAGE
echo sqli ID
echo ID=master, msdb, temp

:END

2. CSVI

在命令行查看、修改CSV檔案的工具。

g|700

[!info] 操作細節
參考:https://github.com/hymkor/csvi

3. 💡 相關鏈接

💡 解說文章:
✅ GitHub - hymkor/sqlbless: The Command-line Database Client: https://github.com/hymkor/sqlbless
✅ GitHub - hymkor/csvi: Terminal CSV Editor: https://github.com/hymkor/csvi

4. 教學影片

https://youtu.be/_cxBQKpfUds

##

您可能也會有興趣的類似文章


Viewing all articles
Browse latest Browse all 897

Trending Articles