Skip to content
/ sqluv Public

simple terminal UI for RDBMS & CSV/TSV/LTSV at local/https/s3

License

Notifications You must be signed in to change notification settings

nao1215/sqluv

Repository files navigation

dbms_demo

The sqluv (sql + love) is a straightforward text-based user interface designed for interacting with various Relational Database Management Systems (RDBMS) as well as CSV, TSV, and LTSV files. The sqluv read CSV, TSV, and LTSV files from local storage, HTTPS, and Amazon S3. The sqluv automatically decompresses compressed files in .gz, .bz2, .xz, and .zst formats.With sqluv, executing SQL queries becomes a user-friendly experience, allowing seamless connections to databases or local files with ease.

The sqluv is a command derived from nao1215/sqly. Its starting point is to provide a more user-friendly interface for writing SQL compared to sqly.

Warning

sqluv is under development. You use sqluv for viewer. Do not execute UPDATE or DELETE in the production environment.

Key Features

  • Multi-DBMS Support: Connect and interact with popular database systems like MySQL, PostgreSQL, SQLite3, and SQL Server.
  • File Compatibility: Read data from files in CSV, TSV, and LTSV formats from HTTPS, S3, and local storage.
  • Support Compressed File: Automatically decompresses compressed files in .gz, .bz2, .xz, and .zst.
  • Query History: Save and access SQL query history for easy reference. Fuzzy search is also available.
  • Customizable Themes: sqluv supports multiple color themes, enabling customization of the interface based on user preference.

How to install

Use "go install"

go install github.com/nao1215/sqluv@latest

Use homebrew

brew install nao1215/tap/sqluv

Supported OS, File Format, Compressed Format, DBMS, go version

  • Windows/macOS/Linux
  • CSV/TSV/LTSV (file://, http://, https://)
  • gz/bz2/xz/zst
  • MySQL/PostgreSQL/SQLite3/SQL Server
  • go1.24 or later

How to use

Syntax

The sqluv interface prioritizes ease of use. Upon launching without specifying a file path, users are prompted to enter connection details for their database. Configuration is saved, allowing for easy reconnections in the future. Below is a brief overview of the capabilities:

sqluv [FILE_PATHS/HTTPS URL/S3 URL]  ※ Supported file formats: CSV, TSV, LTSV

By running this command with the relevant file paths, users can initiate interactions with files.

Connect to DBMS

When you start the sqluv command without specifying a file path, the following screen will appear.

first_screen

Please enter the connection information for the DBMS you want to connect to.

dbms_connection

If the connection is successful, database connection information will be saved in the configuration file. The next time you start the sqluv command, you will be able to select the DBMS you want to connect to from the list.

dbms_list

home_screen

Execute SQL query

To execute a SQL query, enter the SQL query in the query text area and press the execute button or Ctrl + e. When you select the table name on the sidebar and press the Ctrl + e, the sqluv executes the SELECT * FROM ${TABLE_NAME} LIMIT 100 query.

To search for a table name, press the / key at the sidebar. The sqluv will display the search field at the footer. If you press the ESC key, the search field will be cleared.

sql_query

To show/hide columns, press the Space key at the sidebar. If you press the Space key at the sidebar, the sqluv display the table ddl.

ddl

SQL query history

If you execute a SQL query, the history will be saved in the ~/.config/sqluv/history.db. So, you can look up the history by pressing the history button.

history_button

The sqluv supports fuzzy search. You can search for the history by typing the keyword. If you select the history, the SQL query will be copied to the input field.

history_list

Import CSV/TSV/LTSV

Please specify a file path (or url) when executing the sqluv command:

※ file at http/https
sqluv https://raw.githubusercontent.com/nao1215/sqluv/refs/heads/main/testdata/actor.csv
 
※ file at s3. file is compressed in gz format.
sqluv s3://not-exist-s3-bucket/user.csv.gz
 
※ Multiple files
sqluv https://raw.githubusercontent.com/nao1215/sqluv/refs/heads/main/testdata/actor.csv s3://not-exist-s3-bucket/user.tsv testdata/sample.ltsv

The file will be loaded before launching the TUI. When the sqluv import csv/tsv/ltsv, the sqluv checks the file extension and determines the file format. If the file extension is not csv/tsv/ltsv, the sqluv will display an error message. The sqluv does not automatically detect the file format.

sqluv_demo

Save the result to a file

You can save the result to a file by pressing the Ctrl + s key. The sqluv will ask you to enter the file path. The supported file formats are CSV, TSV, and LTSV.

save_result

Key bindings

Key Description
Ctrl + d Quit
Ctrl + e Execute the SQL query
Ctrl + h Display the SQL query history
Ctrl + c Copy the selected sql query
Ctrl + v Paste the copied text
Ctrl + x Cut the selected text
Ctrl + s Save the result to a file
Ctrl + t Change the theme
/ Search the table name (when the focus is on the sidebar)
ESC Clear the search field (when the focus is on the sidebar)
Space Show/Hide Columns (when the focus is on the sidebar)
Enter Show the table DDL (when the focus is on the sidebar)
F1 Focus on the sidebar
F2 Focus on the query text area
F3 Focus on the query result table
TAB Move to the next field
Shift + TAB Move to the previous field

Color theme

Defaulut

color_default

Sublime

color_sublime

VS Code

color_vscode

Atom

color_atom

Dark

color_dark

Light

color_light

Solarized

color_solarized

Monokai

color_monokai

Nord

color_nord

Cappuccino

color_cappuccino

Gruvbox

color_gruvbox

Tokyo Night

color_tokyo_night

Dracula

color_dracula

Cyber Neon

color_cyber_neon

Earthy Tones

color_earthy_tones

Royal Inferno

color_royal_inferno

Altenative Tools

Name Description
jorgerojas26/lazysql A cross-platform TUI database management tool written in Go.
vladbalmos/mitzasql MySQL command line / text based interface client
TaKO8Ki/gobang A cross-platform TUI database management tool written in Rust

Contributing

First off, thanks for taking the time to contribute! See CONTRIBUTING.md for more information. Contributions are not only related to development. For example, GitHub Star motivates me to develop!

If you introduce sqluv on social media or blogs, more users will discover it, and we can gather more ideas for improvement. We hope you enjoy using sqluv!

Star History Chart

Contact

If you would like to send comments such as "find a bug" or "request for additional features" to the developer, please use one of the following contacts.

LICENSE

MIT License