Skip to main content
Skip to main content

Using JupySQL with ClickHouse

In this guide we'll show an integration with ClickHouse.

We will use JupySQL to run queries on top of ClickHouse. Once the data is loaded, we'll visualize it via SQL plotting.

The integration between JupySQL and ClickHouse is made possible by the use of the clickhouse_sqlalchemy library. This library allows for easy communication between the two systems, and enables users to connect to ClickHouse and pass the SQL dialect. Once connected, users can run SQL queries directly from the Clickhouse native UI, or from the Jupyter notebook directly.

Note: you may need to restart the kernel to use updated packages.

You'd need to make sure your Clickhouse is up and reachable for the next stages. You can use either the local or the cloud version.

Note: you will need to adjust the connection string according to the instance type you're trying to connect to (url, user, password). In the example below we've used a local instance. To learn more about it, check out this guide.

  • clickhouse://default:***@localhost:8123/default Done.
  • clickhouse://default:***@localhost:8123/default Done.
  • clickhouse://default:***@localhost:8123/default Done.
count()
1999657
  • clickhouse://default:***@localhost:8123/default Done.
pickup_ntaname
Morningside Heights
Hudson Yards-Chelsea-Flatiron-Union Square
Midtown-Midtown South
SoHo-Tribeca-Civic Center-Little Italy
Murray Hill-Kips Bay
  • clickhouse://default:***@localhost:8123/default Done.
round(avg(tip_amount), 2)
1.68
  • clickhouse://default:***@localhost:8123/default Done.
passenger_countaverage_total_amount
022.69
115.97
217.15
316.76
417.33
516.35
616.04
759.8
836.41
99.81
  • clickhouse://default:***@localhost:8123/default Done.
pickup_datepickup_ntanamenumber_of_trips
2015-07-01Bushwick North2
2015-07-01Brighton Beach1
2015-07-01Briarwood-Jamaica Hills3
2015-07-01Williamsburg1
2015-07-01Queensbridge-Ravenswood-Long Island City9
  • clickhouse://default:***@localhost:8123/default Skipping execution...

histogram example

histogram second example