From the course: Advanced Python: Practical Database Examples

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Solution: Ingest data and visualize it using Matplotlib

Solution: Ingest data and visualize it using Matplotlib - Python Tutorial

From the course: Advanced Python: Practical Database Examples

Solution: Ingest data and visualize it using Matplotlib

(bright music) - [Instructor] Let's practice ingesting data from a database in Jupyter Notebook. We'll start by importing SQLAlchemy. SQLAlchemy will help us connect to the database. To connect to the SQLite database, we'll create an engine. The input will be our SQLite file with our data in it. That's sqlite:///landon.sqlite. We'll ingest the data with pandas. And we need as pd so we can reference it as pd in our file. To read in the table we'll use the read_sql_table function and pass in our table name along with a few other inputs. These include the connection and the index column. Order_id will act as our primary key, so that's why we set it in our index column. Let's visualize the data. We can sort the order totals and view them with the sort_values function. We'll use that on the data frame. We'll sort the values by order total. It looks like one of the smallest orders was $3 and the largest for $900. We can also…

Contents