ClickHouse / clickhouse-js

Official JS client for ClickHouse DB
https://clickhouse.com
Apache License 2.0
217 stars 26 forks source link

Add connection url support to the client #228

Closed PmegaOcalc closed 6 months ago

PmegaOcalc commented 8 months ago

Use case

We set database environment variables based on the standard format of xxx://[userspec@][hostspec][/dbname][?paramspec] Clickhouse js client currently doesn't support it and we need to specify the env variables inconsistently to other databases.

Describe the solution you'd like

Add support for connection string like clickhouse://[user_info@][hosts_and_ports][/dbname][?query_parameters] as it is already supported in clickhouse https://github.com/ClickHouse/ClickHouse/pull/50689

Additional context

ClickHouseClientConfigOptions defines the connection options

slvrtrn commented 7 months ago

I will add URL support for http[s]://[username]:[password]@[host]:[port]/[database] in the next version and deprecate host (that was not the best name for it).

slvrtrn commented 7 months ago

@PmegaOcalc, regarding [?query_parameters]/[?paramspec].

In the CLI client, it works like:

clickhouse-client clickhouse://localhost/my_database?s

# equivalent to:
clickhouse-client clickhouse://localhost/my_database -s

Would you expect CHJS to be (almost) entirely configurable via the URL, similar to the CLI?

PmegaOcalc commented 7 months ago

yes, please

slvrtrn commented 7 months ago

@PmegaOcalc, will be included in 1.0.0, ETA ~few weeks.

slvrtrn commented 6 months ago

@PmegaOcalc, 1.0.0 is out; URL configuration is supported now.