mathaou / termdbms Goto Github PK
View Code? Open in Web Editor NEWA TUI for viewing and editing database files.
License: MIT License
A TUI for viewing and editing database files.
License: MIT License
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:
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!
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)
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
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)
);
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 :
Is there something that I missed?
This looks neat but it takes several minutes to open a 10 GB sqlite file containing 40 million rows.
It does eventually render the interface, but it's taking 38 GB memory according to macOS Activity Monitor.
DB Browser for SQLite is able to work with this DB without loading the entire DB into memory (it's consuming 800 MB RAM).
Loading the entire DB into memory would be OK if it's done in a more memory-efficient way (my system could handle taking 1.5x the size of the sqlite db file but not 3.8x)
Once the interface loaded, I got this crash when I pressed a button:
panic: runtime error: slice bounds out of range [1450:61]-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------┤ 1450, 0
goroutine 561 [running]:
github.com/mathaou/termdbms/viewer.DisplaySelection(0xc203347600)
/Users/hubert/go/pkg/mod/github.com/mathaou/[email protected]/viewer/ui.go:250 +0x5f3
github.com/mathaou/termdbms/viewer.AssembleTable(0xc203347600?)
/Users/hubert/go/pkg/mod/github.com/mathaou/[email protected]/viewer/tableutil.go:18 +0x7b
github.com/mathaou/termdbms/viewer.TuiModel.View.func1(0xc203e34880)
/Users/hubert/go/pkg/mod/github.com/mathaou/[email protected]/viewer/viewer.go:152 +0x2e
created by github.com/mathaou/termdbms/viewer.TuiModel.View
/Users/hubert/go/pkg/mod/github.com/mathaou/[email protected]/viewer/viewer.go:151 +0x219
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.
There is also Ent that gives a http and GRPC api to the db.
It supports 5 databases . It’s a ORM though .
hello! do you think this could add libsql support so one can use turso? it behaves like sqlite driver (mostly) i think you need to include an import and then allow the user to pass 'libsql' as the driver. it works with sqlite drivers, i think the ones you already use.
https://github.com/tursodatabase/libsql-client-go#readme
Installation
Install the driver into your module:
go get github.com/tursodatabase/libsql-client-go
Import the driver into your code using a blank import:
import (
_ "github.com/tursodatabase/libsql-client-go/libsql"
)
Ensure all the module requirements are up to date:
go mod tidy
Add support for sqlite3 database files
I can't seem to see in the readme how to change the mode that's listed in the help.
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
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.)
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.