Skip to content

tinybirdco/real-time-python-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build a real-time dashboard in Python with Tinybird and Dash

Use this repository to build a real-time dashboard in Python using Tinybird and Dash. To learn more about this implementation, check out the blog post.

0. Prerequisites

To implement this project, you'll need to have the following installed

  • Python > v3.8
  • Node.js > v18 (to use the Mockingbird CLI)

1. Get started

Clone the repository:

git clone https://github.com/tinybirdco/real-time-python-dashboard.git
cd real-time-python-dashboard

Setup virtual environment:

python -mvenv .e
. .e/bin/activate
echo ".e*" >> .gitignore

Install requirements:

pip install requirements.txt

Install Tinybird CLI

pip install tinybird-cli

2. Create a Tinybird Workspace

If you need a free Tinybird account, sign up here.

Go to ui.tinybird.co and create a Workspace called in either region. Copy your user admin token from the Tokens in the UI. This is the token associated to your email address:

image

3. Authenticate to Tinybird

Authenticate to your Tinybird Workspace

cd data-project
tb auth --token <your user admin token>
echo ".tinyb" >> .gitignore

4. Push Tinybird resources

From the data-project folder, run the following to push the Tinybird Pipes and Data Source to your Workspace:

tb push datasources pipes

5. Stream data to Tinybird

For this demo, you'll use Mockingbird to stream mock data to Tinybird to populate your flight_bookings Data Source with mock flight bookings data.

Install the Mockingbird CLI

npm install -G @tinybirdco/mockingbird-cli
echo "node_modules" >> .gitignore

Start streaming

You can send up to 1,000 rows per second to Tinybird using Mockingbird:

export TB_HOST=<us_gcp OR eu_gcp>
export TB_TOKEN=<your_user_admin_token>
mockingbird-cli tinybird \
--template "Flight Bookings" \
--eps 10  \
--endpoint=$TB_HOST \
--datasource=flight_bookings \
--token=$TB_TOKEN

6. Run the dashboard

From the main project directory:

python app.py

Open http://127.0.0.1:8050/ to view your real-time dashboard.

image

Contributing

If you find any issues or have suggestions for improvements, please submit an issue or a pull request.

License

This code is available under the MIT license. See the LICENSE file for more details.

Need help?

Community SlackTinybird Docs

Authors

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages