Update — Visualize E-commerce Public Data
In the previous post, I wrote about creating a dashboard/data visualization with Streamlit, I use public data that I get from dicoding.com. It’s created with static data from a CSV file and no other technology I used, besides Streamlit.
Get Muhamad Insan R’s stories in your inbox
Join Medium for free to get updates from this writer.
So now, I want to share the updated project data visualization.
- Use the Clickhouse database to read data, migrate from CSV file to database
- Create engine ETL to export from CSV file, clean and transform data, and load to Clickhouse database
- Containerized ETL and Dashboard Streamlit services
- Refactor all services running with the docker-compose (Clickhouse, ETL, Dashboard Streamlit)
Use Clickhouse database
I tried to migrate the data source from CSV files to the Clickhouse database, I considered using Clickhouse because it is lightweight enough, easy to use because it is similar to SQL, and integrating with Python is effortless.
$ pip install clickhouse_connect import clickhouse_connect
# connect to client clickhouse with your credential
client = clickhouse_connect.get_client(host='your-host', username='your-user', password='your-password', port=your-port)
# query
client.command('select * from table-name')Create ETL engine
ETL engine is responsible for extracting data from CSV files, cleaning and transforming data, and saving the data to the Clickhouse database.
The picture above shows the utilitiesdirectory responsible for connecting to the database, extracting data, transforming data, and loading data to the database. Thus, elt.py running all files utilities as a main file.
Containerize with Docker
ETL and Dashboard Streamlit are built with docker for an easier deployment process. In the picture below I show you a line of code of the Dockerfile for both dashboard and ETL services.
Wrap all with docker-compose
Lastly, create docker-compose to wrap all services within one file docker-compose that consists of Clickhouse container, ETL container, and dashboard container.
So, with these updates, I hope people who want to use the project can be more helpful.
Next update
Next update for this project.
- Refactoring to add unit testing
- Add orchestration with Apache Airflow
Source:
https://github.com/muhamadInsan/da-with-python-dicoding-submission










