Get Started

Creating a database engine

Here, you're going to fire up your very first SQL engine. You'll create an engine to connect to the SQLite database 'Chinook.sqlite', which is in your working directory. Remember that to create an engine to connect to 'Northwind.sqlite', Hugo executed the command

engine = create_engine('sqlite:///Northwind.sqlite')

Here, 'sqlite:///Northwind.sqlite' is called the connection string to the SQLite database Northwind.sqlite. A little bit of background on the Chinook database: the Chinook database contains information about a semi-fictional digital media store in which media data is real and customer, employee and sales data has been manually created.

Why the name Chinook, you ask? According to their website,

The name of this sample database was based on the Northwind database. Chinooks are winds in the interior West of North America, where the Canadian Prairies and Great Plains meet various mountain ranges. Chinooks are most prevalent over southern Alberta in Canada. Chinook is a good name choice for a database that intends to be an alternative to Northwind.

This is a part of the course

“Introduction to Importing Data in Python”

View Course

Exercise instructions

  • Import the function create_engine from the module sqlalchemy.
  • Create an engine to connect to the SQLite database 'Chinook.sqlite' and assign it to engine.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import necessary module
from ____ import ____

# Create engine: engine

This exercise is part of the course

Introduction to Importing Data in Python

BeginnerSkill Level
4.7+
88 reviews

Learn to import data into Python from various sources, such as Excel, SQL, SAS and right from the web.

In this chapter, you'll learn how to extract meaningful data from relational databases, an essential skill for any data scientist. You will learn about relational models, how to create SQL queries, how to filter and order your SQL records, and how to perform advanced queries by joining database tables.

Exercise 1: Introduction to relational databasesExercise 2: Pop quiz: The relational modelExercise 3: Creating a database engine in PythonExercise 4: Creating a database engine
Exercise 5: What are the tables in the database?Exercise 6: Querying relational databases in PythonExercise 7: The Hello World of SQL Queries!Exercise 8: Customizing the Hello World of SQL QueriesExercise 9: Filtering your database records using SQL's WHEREExercise 10: Ordering your SQL records with ORDER BYExercise 11: Querying relational databases directly with pandasExercise 12: Pandas and The Hello World of SQL Queries!Exercise 13: Pandas for more complex queryingExercise 14: Advanced querying: exploiting table relationshipsExercise 15: The power of SQL lies in relationships between tables: INNER JOINExercise 16: Filtering your INNER JOINExercise 17: Final Thoughts

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free