DEV Community

Cover image for sqluv - simple terminal UI for DBMS & local CSV/TSV/LTSV
nchika
nchika

Posted on

1

sqluv - simple terminal UI for DBMS & local CSV/TSV/LTSV

I previously released the sqly command. sqly is a tool that allows you to execute SQL on CSV, TSV, LTSV, JSON, and Excel files, and it provided a custom shell to enhance user-friendliness. I have compiled articles about sqly here.

When expanding sqly's features, I reconsidered the interface and realized that a simpler Text User Interface (TUI) would make it more intuitive. As I envisioned a TUI, I came up with the idea that "it would be even more useful if the same UI could connect to a DBMS."

This thought process led me to develop the sqluv command. The name comes from SQL + LOVE. I chose this name with the hope that sqluv would help people become more familiar with SQL.

sqlv demo

sqlv demo

Support OS and DBMS

  • Windows
  • macOS
  • Linux
  • MySQL
  • PostgreSQL
  • SQLite3
  • SQL Server

Execution Example: Running SQL on CSV/TSV/LTSV

Image description

When sqluv receives file paths (multiple files supported) as startup arguments, it automatically loads the files and stores their data in an in-memory SQLite3 database. The table names are derived from the filenames by removing their extensions (e.g., if the file is sample.csv, the table name will be sample).

Due to the nature of writing data into SQLite3, executing an UPDATE statement in SQL does not modify the original local files. In the original sqly, there was a feature to reflect UPDATE results back into the local files, so I plan to port this feature to sqluv at a later time.

Database Connection Feature

If no file paths are specified at startup, sqluv enters DBMS mode.

  • New: Enter new database connection details and connect.
  • List: Select from previously saved connection details and connect.

Image description

The New Database Connection screen, which appears after pressing the New button, allows users to input connection details. If the connection is successful, the information is saved in ~/.config/sqluv/dbms.yml.

Image description

The Saved Connections screen, which appears after pressing the List button, displays a list of previously entered connection names. Users can navigate the list using the arrow keys and press Enter to connect.

Currently, there is no feature to manually delete connection entries. However, if a connection attempt fails, a modal will appear asking whether to delete the failed connection entry.

Image description

HOME Screen

The HOME screen consists of:

  • Sidebar: Displays the list of tables.
  • Top-right area: SQL input field.
  • Bottom-right area: SQL execution result display.

Press Ctrl-D or ESC to exit the application, and use TAB or Shift-TAB to switch focus between elements.

Image description

After entering an SQL query and pressing the Execute Query button, the table data is displayed. Users can navigate and scroll through the table using the arrow keys or mouse.

Image description

Initially, I planned to execute SQL queries with Ctrl-Enter, but due to technical limitations where Ctrl-Enter was mistakenly recognized as a regular Enter, I had to reluctantly introduce the Execute Query button instead.

Conclusion

sqluv is a newly developed command, and I expect there may still be some bugs. Moving forward, my goals are to fix bugs and provide a more user-friendly TUI.

To keep my development motivation high, I’d really appreciate it if you could press the GitHub Star button! Even better, if you’re willing to sponsor me, that would be amazing (I was recently surprised to receive my very first sponsor!). Bug reports are also more than welcome.

Thank you all for reading until the end!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
barim profile image
CodeCadim by Brahim Hamdouni

Nice piece of software !

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay