WIP: add basic sqlite command interpreter #538
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While sqlite obviously ships its own commandline interface to operate
on databases, it is not always as widely available as one would
expect. For example, I'm working on an embeded device here that runs a
custom Linux distribution, and sqlite is not shipped with the
distro. Deploying a binary of sqlite fails because it depends on
shared libraries, and going down that rabbit hole is a problem that
can be pretty hairy to solve. And compiling sqlite itself statically
isn't quite workable for all sorts of reasons.
Which brings us to this project: golang compiles statically by
default, and I've successfully deployed a small program using this
library on the embedded device without problems. But to do some more
debugging, I now need an actual SQL shell to run commands.
So I wrote this small command that creates a go-sqlite3 binary which
behaves somewhat like the normal sqlite command. It's way more limited
of course: output isn't really formatted correctly into tables and
only crude functionality is implemented. But databases can be read
with SELECT queries, which can be passed on the commandline or through
a crude shell-like commandline prompt.
This is similiar to the commands in _example but is actually usable,
so I have thrown it in the standard
cmd
subdirectory, in the hope itcan be installed directly.
Still missing:
commandline history. can be implemented with ishell or
readline or GNU readline
table formatting. possibly: tabwriter, tablewriter,
columnize, cli-table