Execute request
Executes a request with the specified parameters
- Parameters
- Advanced call ?
Function ExecuteRequest(Val Connection, Val Request, Val Session = Undefined) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | --conn | Arbitrary | ✔ | Connection settings or object (for gRPC) |
| Request | --req | Structure Of KeyAndValue | ✔ | Request data. See GetRequestSettings |
| Session | --session | Structure Of KeyAndValue | ✖ | Session settings. See GetSessionSettings |
Returns
Map Of KeyAndValue - Execution result
| Parameter | Description |
|---|---|
| proxy | InternetProxy or a structure with fields Protocol, Host, Port, User, Password, UseOSAuthentication |
| timeout | Request execution timeout |
| adv_response | Formats the response as a complete HTTP structure with fields code, body, and headers |
| retries | Number of HTTP request send attempts on 5** status codes or internal client errors |
| dontwait | Creates a background job and returns its data (for 1C and OneScript only) |
1C:Enterprise/OneScript code example
// Connection settings
URL = "http://localhost:8123";
Login = "bayselonarrend";
Password = "12we...";
Authorization = New Structure(Login, Password);
Connection = OPI_ClickHouse.GetHTTPConnectionSettings(URL, Authorization);
// Request (table creation)
QueryText = "CREATE TABLE IF NOT EXISTS events (
| id UInt64,
| timestamp DateTime,
| user_id UInt32,
| event_type String,
| payload String
|) ENGINE = MergeTree()
|ORDER BY (timestamp, id)";
Request = OPI_ClickHouse.GetRequestSettings(QueryText);
Result = OPI_ClickHouse.ExecuteRequest(Connection, Request);
// Request (data insertion)
QueryText = "INSERT INTO events FORMAT JSON";
DataFormat = "JSON";
DataArray = New Array;
CurrentDate = Date("20260101100000");
Record1 = New Structure;
Record1.Insert("id" , 1);
Record1.Insert("timestamp" , CurrentDate);
Record1.Insert("user_id" , 100);
Record1.Insert("event_type", "click");
Record1.Insert("payload" , "{}");
Record2 = New Structure;
Record2.Insert("id" , 2);
Record2.Insert("timestamp" , CurrentDate);
Record2.Insert("user_id" , 200);
Record2.Insert("event_type", "hover");
Record2.Insert("payload" , "{}");
DataArray.Add(Record1);
DataArray.Add(Record2);
Meta = New Array;
Meta.Add(New Structure("name,type", "id" , "UInt64"));
Meta.Add(New Structure("name,type", "timestamp" , "DateTime"));
Meta.Add(New Structure("name,type", "user_id" , "UInt32"));
Meta.Add(New Structure("name,type", "event_type", "String"));
Meta.Add(New Structure("name,type", "payload" , "String"));
Data = New Structure("meta,data", Meta, DataArray);
Database = "default";
RequestID = String(New UUID());
Request = OPI_ClickHouse.GetRequestSettings(QueryText, Database, RequestID, Data, DataFormat);
Result = OPI_ClickHouse.ExecuteRequest(Connection, Request);
// Request with external table
TableName = "ext_users";
ColoumnsStruct = New Structure;
ColoumnsStruct.Insert("id" , "UInt64");
ColoumnsStruct.Insert("name", "String");
Tab = Chars.Tab;
TableData = "1" + Tab + "John
|2" + Tab + "Jane
|3" + Tab + "Bob";
ExternalTable = OPI_ClickHouse.GetExternalTableStructure(TableName, ColoumnsStruct, TableData, "TSV");
ExternalTablesArray = New Array;
ExternalTablesArray.Add(ExternalTable);
QueryText = "SELECT * FROM ext_users WHERE id > 1";
Request = OPI_ClickHouse.GetRequestSettings(QueryText, , , , "JSON", ExternalTablesArray);
Result = OPI_ClickHouse.ExecuteRequest(Connection, Request);
// Selection
SelectionText = "SELECT * FROM events";
Request = OPI_ClickHouse.GetRequestSettings(SelectionText, , , , "JSON");
Result = OPI_ClickHouse.ExecuteRequest(Connection, Request);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint clickhouse ExecuteRequest \
--conn "{'transport':'grpc','user':'bayselonarrend','password':'***','auth_type':'basic','address':'http://127.0.0.1:9101'}" \
--req "{'query':'SELECT * FROM events_stream_test ORDER BY id','format':'JSON'}"
:: JSON data can also be passed as a path to a .json file
oint clickhouse ExecuteRequest ^
--conn "{'transport':'grpc','user':'bayselonarrend','password':'***','auth_type':'basic','address':'http://127.0.0.1:9101'}" ^
--req "{'query':'SELECT * FROM events_stream_test ORDER BY id','format':'JSON'}"
Result
{
"status": 200,
"result": true,
"body": {
"meta": [
{
"name": "id",
"type": "UInt64"
},
{
"name": "value",
"type": "String"
}
],
"data": [
{
"id": "1",
"value": "test1"
},
{
"id": "2",
"value": "test2"
}
],
"rows": 2,
"statistics": {
"elapsed": 0.000928,
"rows_read": 2,
"bytes_read": 44
}
},
"headers": {
"Date": "Tue, 26 May 2026 14:39:45 GMT",
"Connection": "Keep-Alive",
"X-ClickHouse-Server-Display-Name": "clickhouse",
"Transfer-Encoding": "chunked",
"X-ClickHouse-Query-Id": "1b18b86d-0846-4997-a1b8-e99832c0e291",
"X-ClickHouse-Format": "JSON",
"X-ClickHouse-Timezone": "Europe/Moscow",
"Keep-Alive": "timeout=3",
"X-ClickHouse-Summary": "{\"read_rows\":\"2\",\"read_bytes\":\"44\",\"written_rows\":\"0\",\"written_bytes\":\"0\",\"total_rows_to_read\":\"0\",\"...",
"Content-Type": "application/json; charset=UTF-8"
}
}