Project: ClickHouse (App Definition and Development / Database)
File: grpc.md

slug: /en/interfaces/grpc sidebar_position: 19 sidebar_label: gRPC Interface ClickHouse supports interface. It is an open source remote procedure call system that uses HTTP/2 and . The implementation of gRPC in ClickHouse supports: SSL; authentication; sessions; compression; parallel queries through the same channel; cancellation of queries; getting progress and logs; external tables. The specification of the interface is described in . To use the gRPC interface set `grpc_port` in the main . Other configuration options see in the following example: ```xml <grpcport>9100</grpcport> <grpc> <enablessl>false</enablessl> <!-- The following two files are used only if SSL is enabled --> <sslcertfile>/path/to/sslcertfile</sslcertfile> <sslkeyfile>/path/to/sslkeyfile</sslkeyfile> <!-- Whether server requests client for a certificate --> <sslrequireclientauth>false</sslrequireclientauth> <!-- The following file is used only if sslrequireclient_auth=true --> <sslcacertfile>/path/to/sslcacertfile</sslcacert_file> <!-- Default compression algorithm (applied if client doesn't specify another algorithm, see result_compression in QueryInfo). Supported algorithms: none, deflate, gzip, stream_gzip --> <compression>deflate</compression> <!-- Default compression level (applied if client doesn't specify another level, see result_compression in QueryInfo). Supported levels: none, low, medium, high --> <compressionlevel>medium</compressionlevel> <!-- Send/receive message size limits in bytes. -1 means unlimited --> <maxsendmessagesize>-1</maxsendmessagesize> <maxreceivemessagesize>-1</maxreceivemessagesize> <!-- Enable if you want to get detailed logs --> <verboselogs>false</verboselogs> </grpc> ``` You can write a client in any of the programming languages supported by gRPC using the provided . Or you can use a built-in Python client. It is placed in in the repository. The built-in client requires Python modules. The client supports the following arguments: `--help` Shows a help message and exits. `--host HOST, -h HOST` A server name. Default value: `localhost`. You can use IPv4 or IPv6 addresses also. `--port PORT` A port to connect to. This port should be enabled in the ClickHouse server configuration (see `grpc_port`). Default value: `9100`. `--user USERNAME, -u USERNAME` A user name. Default value: `default`. `--password PASSWORD` A password. Default value: empty string. `--query QUERY, -q QUERY` A query to process when using non-interactive mode. `--database DATABASE, -d DATABASE` A default database. If not specified, the current database set in the server settings is used (`default` by default). `--format OUTPUTFORMAT, -f OUTPUTFORMAT` A result output . Default value for interactive mode: `PrettyCompact`. `--debug` Enables showing debug information. To run the client in an interactive mode call it without `--query` argument. In a batch mode query data can be passed via `stdin`. Client Usage Example In the following example a table is created and loaded with data from a CSV file. Then the content of the table is queried. ``` bash ./clickhouse-grpc-client.py -q "CREATE TABLE grpcexampletable (id UInt32, text String) ENGINE = MergeTree() ORDER BY id;" echo -e "0,Input data for\n1,gRPC protocol example" > a.csv cat a.csv | ./clickhouse-grpc-client.py -q "INSERT INTO grpcexampletable FORMAT CSV" ./clickhouse-grpc-client.py --format PrettyCompact -q "SELECT * FROM grpcexampletable;" ``` Result: ``` text idtext 0 Input data for 1 gRPC protocol example ```