ClickHouse/programs/client/clickhouse-client.xml
Azat Khuzhin 4564a1ef29 Add ability to override connection settings based on connection names
This is somehow analog of .netrc [1].

  [1]: https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html

The follow options can be overwritten on a per-hostname/connection
basis:
- hostname
- port
- secure
- user
- password
- database
- history_file

Also note, that you can have multiple settings for one hostname, can be
useful to distinguish readonly from non-readonly for example.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-28 17:01:12 +01:00

85 lines
3.2 KiB
XML

<!-- Config set into /etc/clickhouse-client/. It's used if no other configs are found. -->
<config>
<openSSL>
<client> <!-- Used for connection to server's secure tcp port -->
<loadDefaultCAFile>true</loadDefaultCAFile>
<cacheSessions>true</cacheSessions>
<disableProtocols>sslv2,sslv3</disableProtocols>
<preferServerCiphers>true</preferServerCiphers>
<!-- Use for self-signed: <verificationMode>none</verificationMode> -->
<invalidCertificateHandler>
<!-- Use for self-signed: <name>AcceptCertificateHandler</name> -->
<name>RejectCertificateHandler</name>
</invalidCertificateHandler>
</client>
</openSSL>
<!--
It's a custom prompt settings for the clickhouse-client
Possible macros:
{host}
{port}
{user}
{display_name}
You can also use colored prompt, like in [1].
[1]: https://misc.flogisoft.com/bash/tip_colors_and_formatting
But note, that ClickHouse does not use readline anymore, instead it uses
replxx. This means that you don't need the following:
- RL_PROMPT_START_IGNORE (\001)
- RL_PROMPT_END_IGNORE (\002)
-->
<prompt_by_server_display_name>
<default>{display_name} :) </default>
<test>{display_name} \e[1;32m:)\e[0m </test> <!-- if it matched to the substring "test" in the server display name - -->
<production>{display_name} \e[1;31m:)\e[0m </production> <!-- if it matched to the substring "production" in the server display name -->
</prompt_by_server_display_name>
<!--
Settings adjustable via command-line parameters
can take their defaults from that config file, see examples:
<host>127.0.0.1</host>
<port>9440</port>
<secure>1</secure>
<user>dbuser</user>
<password>dbpwd123</password>
<format>PrettyCompactMonoBlock</format>
<multiline>1</multiline>
<multiquery>1</multiquery>
<stacktrace>1</stacktrace>
<database>default2</database>
<pager>less -SR</pager>
<history_file>/home/user/clickhouse_custom_history.log</history_file>
<max_parser_depth>2500</max_parser_depth>
The same can be done on user-level configuration, just create & adjust: ~/.clickhouse-client/config.xml
-->
<!-- Analog of .netrc -->
<![CDATA[
<connections_credentials>
<connection>
<!-- Name of the connection, host option for the client.
"host" is not the same as "hostname" since you may want to have different settings for one host,
and in this case you can add "prod" and "prod_readonly".
Default: "hostname" will be used. -->
<name>default</name>
<!-- Host that will be used for connection. -->
<hostname>127.0.0.1</hostname>
<port>9000</port>
<secure>1</secure>
<user>default</user>
<password></password>
<database></database>
<!-- '~' is expanded to HOME, like in any shell -->
<history_file></history_file>
</connection>
</connections_credentials>
]]>
</config>