xo / usql

Universal command-line interface for SQL databases
MIT License
9.07k stars 352 forks source link

connect to clickhouse over http from cmdline #463

Closed tarasglek closed 6 months ago

tarasglek commented 6 months ago

Hi, the clickhouse driver supports native and http. I can't figure out how to connect to clickhouse over http using usql.

The following works inside usql

\c clickhouse https://user:pass@host/db?secure

Why I can't a pass this as a param on cmdline?

usql clickhouse:https://user:pass@host/db?secure
error: clickhouse: dial tcp: lookup https: no such host

or

usql clickhouse+https://user:pass@host/db?secure
error: invalid transport protocol

Neither works. Where am I getting the syntax wrong?

kenshaw commented 6 months ago

I've read the Clickhouse driver code, this needs to be added via dburl generating the schema with a +http and +https scheme. Alternately, could use completely different schemes. I'll look into this and try to get an implementation out in the next few hours.

kenshaw commented 6 months ago

Pushing a release now -- Clickhouse URLs should now support clickhouse+http and clickhouse+https. I have not thoroughly vetted this, please provide feedback if this meets your expectations.

kenshaw commented 6 months ago

@tarasglek I was just rereading your original comment. The commit I pushed adds support for clickhouse+http:// and clickhouse+https:// as URL schemes, however it's worth noting that \c clickhouse https://user:pass@host/db?secure should have been able to connect.

I would assume if it failed, you were on an older version of usql -- if so, could you share what version of usql you encountered this with?

Regardless, as soon as the builds have finished, I'll set the release and when you update to the latest v0.19.1 version of usql, all of the URL forms you shared above should work. If they don't, please open a new issue and I'll debug further.

tarasglek commented 6 months ago

Wow, thanks for quick turn-around, I wish I reported this earlier :) Verified that the clickhouse+ way works as one would expect!

\c clickhouse https://user:pass@host/db?secure did work, sorry if i wasn't clear.