The samples contained in this directory demonstrate how to use MariaDB Connector/Python in combination with libraries Plotly and Pandas to analyze and visualize data.
Note: This directory assumes that you've already installed the necessary requirements for using MariaDB Connector/Python. If you haven't, please refer to the root README of this repository.
The samples in this directory rely on flight data that is available from the United States Bureau of Transport. For more information on database preparation make sure you check out the following repository before continuing:
There are two ways to utilize MariaDB Connector/Python with Plotly and Pandas in this directory. Both options contain the same examples.
- By executing the Python code files directly.
- By using Jupyter Lab to facilitate the code development, execution, and visualization.
Regardless of which option you choose you will need to do the following to prepare a suitable enviroment.
-
Open a new terminal at this location and create a new virtual environment using the following command:
$ python3 -m venv demo
-
Activate the virtual environment.
$ . demo/bin/activate
-
Download and install the necessary Python packages.
$ pip install mariadb plotly pandas
-
Update the connection configuration in the demo files to point to a valid database instance.
For example:
config = { 'host': 'analytics-demo.mdb0001390.db.skysql.net', 'port': 5001, 'user': 'DB00004088', 'password': 'Password123!, 'database': 'travel', 'ssl': True }
-
Execute the demo files.
$ python src/demo_1.py $ python src/demo_2.py $ python src/demo_3.py $ python src/demo_4.py
Demo_1 will output directly to the terminal, while Demo_2/3/4 will display a chart within your default browser.
-
Download and install the necessary Python packages.
$ pip install mariadb plotly pandas jupyterlab
-
Install Jupyter extension to facilitate Plotly rendering.
$ jupyter labextension install jupyterlab-plotly@4.14.3
-
Run Jupyter Lab.
$ jupyter lab
-
Open Demo.ipynb (a Jupyter Notebook file).
7.) Select and Jupyter Notebook cell and run.
Note: Make sure you update the connection configuration!