Aan de slagGa gratis aan de slag

The Hello World of SQL Queries!

Now, it's time for liftoff! In this exercise, you'll perform the Hello World of SQL queries, SELECT, in order to retrieve all columns of the table Album in the Chinook database. Recall that the query SELECT * selects all columns.

Deze oefening maakt deel uit van de cursus

Introduction to Importing Data in Python

Cursus bekijken

Oefeninstructies

  • Open the engine connection as con using the method .connect() on the engine.
  • Execute the query that selects ALL columns from the Album table. Store the results in rs.
  • Store all of your query results in the DataFrame df by applying the .fetchall() method to the results rs.
  • Close the connection!

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import packages
from sqlalchemy import create_engine
import pandas as pd

# Create engine: engine
engine = create_engine('sqlite:///Chinook.sqlite')

# Open engine connection: con


# Perform query: rs
rs = con.execute(____)

# Save results of the query to DataFrame: df
df = pd.DataFrame(____)

# Close connection


# Print head of DataFrame df
print(df.head())
Code bewerken en uitvoeren