infi.clickhouse_orm/examples/db_explorer
dependabot[bot] 32026b0835
Bump werkzeug from 1.0.1 to 2.2.3 in /examples/db_explorer
Bumps [werkzeug](https://github.com/pallets/werkzeug) from 1.0.1 to 2.2.3.
- [Release notes](https://github.com/pallets/werkzeug/releases)
- [Changelog](https://github.com/pallets/werkzeug/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/werkzeug/compare/1.0.1...2.2.3)

---
updated-dependencies:
- dependency-name: werkzeug
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-16 01:48:50 +00:00
..
templates Added usage examples 2020-07-14 21:57:24 +03:00
.gitignore Added usage examples 2020-07-14 21:57:24 +03:00
charts.py Added usage examples 2020-07-15 23:42:40 +03:00
README.md Added usage examples 2020-07-15 23:42:40 +03:00
requirements.txt Bump werkzeug from 1.0.1 to 2.2.3 in /examples/db_explorer 2023-02-16 01:48:50 +00:00
server.py Added usage examples 2020-07-15 23:42:40 +03:00

DB Explorer

This is a simple Flask web application that connects to ClickHouse and displays the list of existing databases. Clicking on a database name drills down into it, showing its list of tables. Clicking on a table drills down further, showing details about the table and its columns.

For each table or column, the application displays the compressed size on disk, the uncompressed size, and the ratio between them. Additionally, several pie charts are shown - top tables by size, top tables by rows, and top columns by size (in a table).

The pie charts are generated using the pygal charting library.

ORM concepts that are demonstrated by this example:

  • Creating ORM models from existing tables using Database.get_model_for_table
  • Queryset filtering
  • Queryset aggregation

Running the code

Create a virtualenv and install the required libraries:

virtualenv -p python3.6 env
source env/bin/activate
pip install -r requirements.txt

Run the server and open http://127.0.0.1:5000/ in your browser:

python server.py

By default the server connects to ClickHouse running on http://localhost:8123/ without a username or password, but you can change this using command line arguments:

python server.py http://myclickhouse:8123/

or:

python server.py http://myclickhouse:8123/ admin secret123