via Python Library

Hydrolix uses the Clickhouse SQL engine, so you can connect to Hydrolix using any of several different Python libraries that support Clickhouse servers. This example uses clickhouse-driver.

To install clickhouse-driver, run the following command:

pip3 install clickhouse-driver

Use the following code snippet to import the client, connect to a Hydrolix instance, and execute a query:

from clickhouse_driver import Client

# Always include settings, it contains some breakers to prevent query the world scenario
settings = {'hdx_query_max_timerange_sec': 604800, 'hdx_query_max_execution_time': 60}

# don't forget to url encode username and password. You can use native tcp port 9440 or http 8088
client = Client.from_url('clickhouse://username:password@<your host name>:9440/sample_project?secure=true')
count = client.execute('select count() from my_project.my_logs where timestamp >= now() - INTERVAL 60 MINUTE', settings=settings)
print(count)

Don't forget to replace the hostname with your own Hydrolix cluster's hostname!