
Usql – A Universal CLI for Databases - nexuist
https://github.com/xo/usql
======
lwb
I was really hoping for \dt but looks like they haven't implemented it yet.
The number one most common thing I look up when I'm using a SQL variant is how
to show the tables. I suppose there would be complications with NoSQL but you
could just show available collections or whatever else it maps to in that
case.

~~~
toomim
Yes, and since "show the tables" isn't in SQL itself, each CLI ends up having
a different command for doing it, which makes a universal CLI appealing to
me... if it can do that.

~~~
paulddraper
> since "show the tables" isn't in SQL itself,

Actually

    
    
        SELECT table_name FROM information_schedule.tables;
    

But yes, that's harder to type/remember than \d.

~~~
lwb
Does that really work for every version of SQL? This might change my life.

~~~
carlineng
information_schema (not "schedule"; GP had a typo in the query) is part of the
ANSI SQL standard[1] so should work with any database that implements the ANSI
standard. Note that not all databases or SQL dialects comply with this.

[1]
[https://en.wikipedia.org/wiki/Information_schema](https://en.wikipedia.org/wiki/Information_schema)

~~~
paulddraper
Thanks.

------
the_duke
I have been looking for a faster alternative to pgcli [1] ( with features like
auto-complete for table names and columns) and was getting excited.

Sadly this is "just" a plain old CLI.

Also: had to install with `go get -tags "no_sqlite3" -u github.com/xo/usql`
since the sqlite3 package did not build.

[1] [https://www.pgcli.com/](https://www.pgcli.com/)

~~~
kbd
It’s at a disadvantage vs pgcli and mycli because they’re in Python and have
access to the excellent Prompt Toolkit (which also powers ipython), while usql
is in Go.

I started using mycli recently and it actually made me joyful about how good
it was. DBeaver is really good but for most things I’d prefer a cli, and the
autocomplete actually makes it faster to use for many things.

~~~
brigandish
I've not used Prompt Toolkit (or usql) but am very interested in making better
cli, what makes Prompt Toolkit so good?

~~~
kbd
Here's a presentation at PyCon 2017 by the author of pgcli and mycli that's a
great answer to your question:

[https://www.youtube.com/watch?v=hJhZhLg3obk](https://www.youtube.com/watch?v=hJhZhLg3obk)

~~~
brigandish
That was really interesting and fired my imagination! Thanks.

------
swasheck
... not to be confused with ... U-SQL

[https://docs.microsoft.com/en-us/u-sql/](https://docs.microsoft.com/en-
us/u-sql/)

~~~
dang
We had one of those too:
[https://news.ycombinator.com/item?id=10301147](https://news.ycombinator.com/item?id=10301147)

------
QuinnyPig
The universal CLI for my preferred database is `dig` if you're old-school,
`drill` if you're not.

Some may argue that DNS isn't really a database, but by that metric, neither
is Redis.

------
dang
Related from last year:
[https://news.ycombinator.com/item?id=17310568](https://news.ycombinator.com/item?id=17310568)

and
[https://news.ycombinator.com/item?id=17299356](https://news.ycombinator.com/item?id=17299356).

2017:
[https://news.ycombinator.com/item?id=13780587](https://news.ycombinator.com/item?id=13780587)

~~~
quizotic
Do you do that by memory? Or do you have some text indexing tool that helps?

~~~
dang
I use HN Search, which is linked from the bottom of most HN pages. That's
definitely a text indexing tool that helps! The search company Algolia
provides it for free—a major service to this community, because not only does
it help users find things, we rely on it heavily for all kinds of moderation
tasks.

It's particularly helpful to include "comments > N" or "points > N" if looking
for old threads.

------
beefsack
Awesome project! Having unified tools is a boon for those of us who work
across many different dialects.

One piece of feedback though - I've never been a huge fan of using backslashes
for anything that isn't escaping as it can get confusing to know when it's
escaping or if it's syntactic (do I use two slashes here? Or three or four?
Especially when piping input or putting stuff in text files).

Very cool though and will be keeping an eye on it!

~~~
anko
If you're interested in this sort of thing, it's worth checking out
[https://drill.apache.org/](https://drill.apache.org/)

It lets you query multiple databases but also join between them. Or say,
translate your mysql table to a local csv file. And if you need it to be
faster you can deploy to hadoop.

worth checking out anyway, I used to use it a lot before i started on Apache
Spark.

------
cube2222
If you like this, check out OctoSQL.

It not only presents a SQL interface to sql databases, NoSQL databases and
files (Excel, csv, json for now), but also lets you join data between them and
use multiple databases at once in queries.

Though it's definitely in an earlier stage and maturity than this, with fewer
supported databases. (Though we do support redis for instance, which this does
not)

~~~
cube2222
The forgotten link:
[https://github.com/cube2222/octosql/](https://github.com/cube2222/octosql/)

------
JakaJancar
How come a standard (network) protocol for SQL RDBMS'es never came to be? Sort
of JDBC, but based on TCP (HTTP?) not Java.

~~~
flukus
Because once you get beyond select and where clauses database diverge a lot in
capabilities and syntax. If all you want is a common interface to send
arbitrary text to an arbitrary RDBMS then ODBC mostly solves this.

