sql

command module
v0.0.0-...-7b00875 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 7 Imported by: 0

README

Overview

Simple SQL CLI, building upon pg and mysql CLI's with a few additional features

Screenshot Example

  • One CLI for Postgres and MySQL
  • Easy multiline editing of queries
  • Unified command to view table schema. DESCRIBE X
  • Display results in a scrollable table, no wrapping

Installation

Via golang toolchain
Prerequisites
  • Need go version 1.22 or greater
  • Make sure your go bin is in your path. Easy way to add that is export PATH="$(go env GOPATH)/bin:$PATH"
Command
go install github.com/azvaliev/sql@latest

Usage

Specify what kind of database you're connecting to via -mysql or -psql flags (required). For additional arguments see sql --help

sql (-mysql OR -psql) (... additional options) --database=example
Application Usage

In the query text area, type any SQL statement followed by ; and hit enter to send the query. Results will be displayed in the above space on the screen.

The text area is multi-line and you can use either the mouse or arrow keys to navigate through the text area.

Unified DESCRIBE, SHOW TABLES, SHOW INDEXES command

Several commands from MySQL have been ported to this CLI for convinience

  • DESCRIBE X command for easily viewing details about a table. See MySQL documentation for details
  • SHOW TABLES command for easily all tables in the current database. It just will return a list of all tables in the current databse
  • SHOW INDEXES FROM X command for viewing indexes on a specific table.
Handling overflowing results

When editing the text area, one can scroll the results section using ctrl or option (MacOS) + corresponding arrow for direction to scroll.

Example: To scroll results up, (ctrl or option) +

How to scroll results

Copy query result

When you run a query and it is succesfully, at the top right on the table you'll see a Copy as CSV or Copy as JSON button, to copy the table results in the desired format

JSON

How to copy results as JSON

CSV

How to copy results as CSV

Copy cell result

Occasionally, one may want to copy the output of a particular cell in the result table, especially for use in subsequent queries.

Just click on the cell you want to copy and it will copy to the clipboard.

How to copy cell result

Safe Mode (MySQL)

MySQL has an option called safe mode, you can enable this feature using the -safe flag when running this application. It helps prevent unbounded update/delete operations

See MySQL Documentation for more details

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳