termdbms: A TUI for viewing and editing databases, written in Go

termdbms: A TUI for viewing and editing databases, written in Go

Database Support
SQLite

made with modernc.org/sqlite, charmbracelet/bubbletea, and charmbracelet/lipgloss

Works with keyboard:

Keyboard Control

... And mouse!

Mouse Control

Roadmap

  • Run SQL queries and display results
  • Add/remove rows/columns/cells
  • Rename anything
  • Filter tables by fuzzy search
  • MySQL/ PostgreSQL support
  • Better editing
  • No-style mode for terminal emulators that don't support ANSI / low power machines.
  • Support for 32-bit machines.

How To Build
Linux
GOOS=linux GOARCH=amd64 go build
ARM (runs kind of slow depending on the specs of the system)
GOOS=linux GOARCH=arm GOARM=7 go build
Windows
GOOS=windows GOARCH=amd64 go build
OSX
GOOS=darwin GOARCH=amd64 go build

Terminal settings

Whatever terminal emulator used should support ANSI escape sequences. If there is an option for 256 color mode, enable it.

Known Issues

  • The headers wig out sometimes in selection mode
  • Possible race conditions with getting data initialized, only happens when debugging?
  • Serializing a numeric string change (like "1234") sometimes appends a decimal at the end, even though go recognizes it as a string when serializing. This is likely a bug at the database driver level, or I am not good at this.
Help:
-p	database path (absolute)
-h	prints this message
Controls:
MOUSE
Scroll up + down to navigate table
Move cursor to select cells for full screen viewing
KEYBOARD
[WASD] to move around cells
[ENTER] to select selected cell for full screen view
[UP/K and DOWN/J] to navigate schemas
[LEFT/H and RIGHT/L] to navigate columns if there are more than the screen allows.
    Also to control the cursor of the text editor in edit mode.
[M(scroll up) and N(scroll down)] to scroll manually
[Q or CTRL+C] to quit program
[B] to toggle borders!
[C] to expand column
[P] in selection mode to write cell to file
[ESC] to exit full screen view, or to enter edit mode
EDIT MODE (cosmetic until serialization is working)
[ESC] to enter edit mode with no pre-loaded text input from selection
When a cell is selected, press [:] to enter edit mode with selection pre-loaded
The text field in the header will be populated with the selected cells text. Modifications can be made freely.
[ESC] to clear text field in edit mode
[ENTER] to save text. Anything besides one of the reserved strings below will overwrite the current cell.
[R] to redo actions, if applicable.
[U] to undo actions, if applicable.
[:q] to exit edit mode
[:s] to save database to a new file
[:s!] to overwrite original database file
[:h] to display help text
Owner
Matt Farstad
Embedded software engineer at Fastenal Company. Go, C/C++/C#, JS, Dart, Python, and Java Developer. Music aficionado.
Matt Farstad
Comments
  • runtime error: integer divide by zero

    runtime error: integer divide by zero

    Hi @mathaou
    Congrat for this project, I wanted to test because I like terminal based tools.

    However, I cannot start sqlite3-viewer :

    Caught panic:
    
    runtime error: integer divide by zero
    
    Restoring terminal...
    
    goroutine 1 [running]:
    runtime/debug.Stack(0x4d, 0x0, 0x0)
    	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
    runtime/debug.PrintStack()
    	/usr/local/go/src/runtime/debug/stack.go:16 +0x25
    github.com/charmbracelet/bubbletea.(*Program).Start.func2(0xc00017c1b0)
    	/home/pierre/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:447 +0xd6
    panic(0x71fa60, 0x9937c0)
    	/usr/local/go/src/runtime/panic.go:965 +0x1b9
    sqlite3-viewer/viewer.(*TuiModel).CellWidth(...)
    	/tmp/app/demo/sqlite-tui/viewer/util.go:33
    sqlite3-viewer/viewer.(*TuiModel).GetBaseStyle(0xc000131bb0, 0x6e7db1, 0xc00000c0a8, 0x0)
    	/tmp/app/demo/sqlite-tui/viewer/util.go:39 +0x86f
    sqlite3-viewer/viewer.handleWidowSizeEvents(0xc000131bb0, 0xc000131810)
    	/tmp/app/demo/sqlite-tui/viewer/events.go:39 +0xae
    sqlite3-viewer/viewer.TuiModel.Update(0xc00015d0b0, 0xc00015d0e0, 0xc00015d110, 0x7, 0x1, 0x110, 0x44, 0x0, 0x3, 0x0, ...)
    	/tmp/app/demo/sqlite-tui/viewer/viewer.go:55 +0xd46
    github.com/charmbracelet/bubbletea.(*Program).Start(0xc00017c1b0, 0x0, 0x0)
    	/home/pierre/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:589 +0x5b9
    main.main()
    	/tmp/app/demo/sqlite-tui/main.go:111 +0x39d
    

    Setup :

    • debian 10
    • go 1.16
    • xterm 256 activated

    Is there something that I missed?

  • Build failes due to

    Build failes due to "imported and not used" error

    go build does not build project due to following error:

    # sqlite3-viewer/viewer viewer/viewer.go:8:2: imported and not used: "github.com/mattn/go-runewidth" as runewidth

    Removing this import from code fixes issue and build finishes successfuly.

  • Missing quoting when tables have

    Missing quoting when tables have "special" names

    I have a database with a table called transaction. Opening it view the viewer:

    panic: SQL logic error: near "transaction": syntax error (1)
    
    goroutine 1 [running]:
    sqlite3-viewer/viewer.(*TuiModel).SetModel(0x987d60, 0x0, 0xc0000142c6)
            termdbms/viewer/events.go:171 +0x765
    main.main()
            termdbms/main.go:113 +0x4e5
    

    Probably only a missing quoting somewhere...

    Schema is:

    CREATE TABLE `transaction` (
            id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
            sheetId INTEGER NOT NULL,
            transactionId INTEGER NOT NULL,
            lineno INTEGER NOT NULL,
            lineId INTEGER NOT NULL REFERENCES line(id)
    );
    
  • No installation instructions + getting started

    No installation instructions + getting started

    I apologize if this is obvious to Go progammers - but how would one go about installing this on ubuntu (wsl2) with a fresh golang install?

    As for getting started instructions, what is the shell command to use it?

    Thanks!

  • Fails to build with 32-bit Go

    Fails to build with 32-bit Go

    This error when trying to build with 32-bit version of Go.

    # sqlite3-viewer/viewer
    viewer\util.go:269:22: constant 9223372036854775807 overflows int
    viewer\util.go:274:22: constant 9223372036854775807 overflows int
    viewer\viewer.go:8:2: imported and not used: "github.com/mattn/go-runewidth" as runewidth
    
    

    Builds OK (after removing the unused import) with 64-bit Go.

    (Also, I'm on Win7, and the terminal codes do not work with ANSI.)

  • Crash on DB with many columns?

    Crash on DB with many columns?

    ts.sqlite.zip

    If I open this file and press down arrow twice I get a crash:

    panic: runtime error: slice bounds out of range [:-1]                                                                                                                                                                                                                                                                                                                                                                             
    
    goroutine 43 [running]:
    sqlite3-viewer/viewer.TruncateIfApplicable(0xc000896340, {0xc00001e680, 0x7})
    	~/go/tuitty/viewer/util.go:99 +0x192
    sqlite3-viewer/viewer.TuiModel.View.func2(0xc00059c070)
    	~/go/tuitty/viewer/viewer.go:121 +0xae5
    created by sqlite3-viewer/viewer.TuiModel.View
    	~/go/tuitty/viewer/viewer.go:106 +0x272
    
  • Rename package to github.com/mathaou/termdbms

    Rename package to github.com/mathaou/termdbms

    go install is a default way to install binaries with the modern version of go. But the current package is not compatible with it.

    Here is my attempt Screenshot 2022-04-15 at 13 06 09

    The error is straightforward. I just update go mod and replace imports (with go imports that because of some reformats).

    I don't update README.md instruction, if you consider that required, I'll do it.

  • Pin go-isatty to fix a Go 1.17 crash on macOS

    Pin go-isatty to fix a Go 1.17 crash on macOS

    This updates go-isatty to fix a crash that happens on startup in macOS for binaries built with Go 1.17 due to some syscall changes. For now, go-isatty must be pinned to a commit it's the next release.

    This commit fixes the issue: https://github.com/mattn/go-isatty/commit/ee4b64cd0185c49ed8fff5ade2c9923657fce6b7 Details: https://github.com/golang/go/issues/46763

  • Fails to view SQLite databases containing STRICT tables

    Fails to view SQLite databases containing STRICT tables

    If I create a STRICT table in a SQLite database:

    CREATE TABLE user(id INTEGER, username TEXT) STRICT;
    

    then try to open it with termdbms, I receive the following error:

    database disk image is malformed: malformed database schema (user) - near "STRICT": syntax error (11)
    
  • Publish a Homebrew package

    Publish a Homebrew package

    This app is awesome and you are awesome for making and sharing it. Have you already started on a package for Homebrew? Happy to help contribute if not

  • Alpha 1.0 Release (Database Agnostic Spreadsheet Program)

    Alpha 1.0 Release (Database Agnostic Spreadsheet Program)

    I've realized that I could turn the program into a database agnostic fully fledged spreadsheet program with about a months worth of work. Any features you'd like? Here's what I have planned:

    • Edit cell
    • Add row below/above
    • Remove row below/above
    • Add column left/right
    • Remove column/right
    • Macros? Need to think about which functions would be most helpful in which circumstances. Currency conversion or something maybe.
    • Cell highlight/coloring
    • Expand column to fill screen
    • Serialize (this is going to be the hardest part because it's different for every database)
    • Copy/paste (going to also be tricky to implement

    That's all for Alpha 1.0 release

    Need to think about input. I need text and dialog boxes, maybe some more fancy stuff, but having mouse / keyboard support for all of this is maybe kind of cluttered so maybe some kind of vim-esque structuring idk

    PRs related to this effort welcome and suggestions / feedback appreciated!

A repository for plotting and visualizing data

gonum/plot is the new, official fork of code.google.com/p/plotinum. It provides an API for building and drawing plots in Go

Jan 5, 2023
Tool that can parse Go files into an abstract syntax tree and translate it to several programming languages.
Tool that can parse Go files into an abstract syntax tree and translate it to several programming languages.

GoDMT GoDMT, the one and only Go Data Model Translator. The goal of this project is to provide a tool that can parse Go files that include var, const,

Nov 28, 2022
Callgraph analysis and visualization for Go
Callgraph analysis and visualization for Go

Gocyto A Go SSA callgraph builder and visualizer, by @protolambda. Features: output to generic Cytoscape JSON format. (list of nodes, list of edges) o

Nov 3, 2022
A repository for plotting and visualizing data

Gonum Plot gonum/plot is the new, official fork of code.google.com/p/plotinum. It provides an API for building and drawing plots in Go. Note that this

Jun 3, 2021
Interactive Terraform visualization. State and configuration explorer.
Interactive Terraform visualization. State and configuration explorer.

Rover - Terraform Visualizer Rover is a Terraform visualizer. In order to do this, Rover: generates a plan file and parses the configuration in the ro

Jan 9, 2023
Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz
Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz

Ltree Visualizer A golang library to visualize postgres ltree type data using DOT language and Graphviz What is Ltree? Ltree is a data type which is u

Jun 12, 2022
Launch-tui is a small TUI app to manage launchD
Launch-tui is a small TUI app to manage launchD

launch-tui Launch-tui is a small TUI app to manage launchD Install You can either install it by donwloading the archive, uncompress it and add the fol

Sep 27, 2022
jt is a CLI tool for viewing and manipulating JIRA issues.

jt - jira-tool jt is a CLI tool for viewing and manipulating JIRA issues. One common example usage to transition an issue to a new status: jt "In Prog

Aug 9, 2022
Kstone is an etcd management platform, providing cluster management, monitoring, backup, inspection, data migration, visual viewing of etcd data, and intelligent diagnosis.
Kstone is an etcd management platform, providing cluster management, monitoring, backup, inspection, data migration, visual viewing of etcd data, and intelligent diagnosis.

Kstone 中文 Kstone is an etcd management platform, providing cluster management, monitoring, backup, inspection, data migration, visual viewing of etcd

Dec 27, 2022
This is the basis of the bot for viewing information on the crp.is exchange in a telegram.
This is the basis of the bot for viewing information on the crp.is exchange in a telegram.

crye_go_bot An example of a telegram bot for working with the crp.is exchange Usage Create config.json to test bot operation Later Test the bot by cre

Jan 15, 2022
A ready to use Pastebin written in Go Lang, fork the files and start editing/using it.

A ready to use Pastebin written in Go Lang, fork the files and start editing/using it.

Dec 31, 2021
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.
  Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

gore Yet another Go REPL that works nicely. Featured with line editing, code completion, and more. (Screencast taken with cho45/KeyCast) Usage gore Af

Jan 2, 2023
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.
  Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

gore Yet another Go REPL that works nicely. Featured with line editing, code completion, and more. (Screencast taken with cho45/KeyCast) Usage gore Af

Jan 7, 2023
Hosty is a command-line utility that allows for fast inspection and editing of /etc/hosts-like files

Hosty Description Hosty is a command-line utility that allows for fast inspection and editing of /etc/hosts-like files. It is written in golang and us

Sep 3, 2021
Flowdog - Framework for inspecting and editing traffic in AWS VPCs
Flowdog - Framework for inspecting and editing traffic in AWS VPCs

Twitter thread flowdog This is an application/framework for inspection and manip

Dec 5, 2022
This is a simple text completion/editing/auto-correction tool I created in Go.
This is a simple text completion/editing/auto-correction tool I created in Go.

Auto Text Completion Tool This is a simple text completion/editing/auto-correction tool I created in Go. The tool receives the following arguments: Th

Oct 25, 2022
Collab - Library for Collaborative Editing (Operational Transform, CRDT) in Go

collab collab is a work-in-progress Go library for collaborating software systems, implementing Operational Transformation (OT), Commutative Replicati

Jan 9, 2022
📽 MovieGo - Video Editing in Golang

?? MovieGo - Video Editing in Golang MovieGo is a Golang library for video editing. The library is designed for fast processing of routine tasks relat

Dec 26, 2022
TUI process monitor written in Go
TUI process monitor written in Go

pst This is TUI process monitor written in Go. Features Monitor process's list, info, tree, open files, Kill process Support OS Mac Linux Requirements

Nov 25, 2022
a TUI for signal messenger, written in Go
a TUI for signal messenger, written in Go

siggo A terminal ui for signal-cli, written in Go. Features vim-style ux useful for quick messages or use $EDITOR to compose fancy ones emoji support,

Jan 2, 2023