2022-08-28 13:53:52 +00:00
---
2022-08-28 13:58:27 +00:00
slug: /en/operations/utilities/odbc-bridge
2022-08-29 16:19:50 +00:00
title: clickhouse-odbc-bridge
2022-08-28 13:53:52 +00:00
---
2018-08-10 14:46:12 +00:00
Simple HTTP-server which works like a proxy for ODBC driver. The main motivation
was possible segfaults or another faults in ODBC implementations, which can
crash whole clickhouse-server process.
This tool works via HTTP, not via pipes, shared memory, or TCP because:
2018-10-13 12:28:08 +00:00
- It's simpler to implement
- It's simpler to debug
2018-08-10 14:46:12 +00:00
- jdbc-bridge can be implemented in the same way
## Usage
`clickhouse-server` use this tool inside odbc table function and StorageODBC.
However it can be used as standalone tool from command line with the following
parameters in POST-request URL:
- `connection_string` -- ODBC connection string.
2024-06-11 12:42:48 +00:00
- `sample_block` -- columns description in ClickHouse NamesAndTypesList format, name in backticks,
2018-08-10 14:46:12 +00:00
type as string. Name and type are space separated, rows separated with
newline.
- `max_block_size` -- optional parameter, sets maximum size of single block.
Query is send in post body. Response is returned in RowBinary format.
## Example:
```bash
$ clickhouse-odbc-bridge --http-port 9018 --daemon
2021-12-09 17:39:18 +00:00
$ curl -d "query=SELECT PageID, ImpID, AdType FROM Keys ORDER BY PageID, ImpID" --data-urlencode "connection_string=DSN=ClickHouse;DATABASE=stat" --data-urlencode "sample_block=columns format version: 1
2018-08-10 14:46:12 +00:00
3 columns:
\`PageID\` String
\`ImpID\` String
\`AdType\` String
" "http://localhost:9018/" > result.txt
$ cat result.txt
12246623837185725195925621517
```