开始使用免费开始使用

Setup the engine and metadata

In this exercise, your job is to create an engine to the database that will be used in this chapter. Then, you need to initialize its metadata.

Recall how you did this in Chapter 1 by leveraging create_engine() and MetaData().

本练习是课程的一部分

Introduction to Databases in Python

查看课程

练习说明

  • Import create_engine and MetaData from sqlalchemy.
  • Create an engine to the chapter 5 database by using 'sqlite:///chapter5.sqlite' as the connection string.
  • Create a MetaData object as metadata.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import create_engine, MetaData


# Define an engine to connect to chapter5.sqlite: engine
engine = create_engine(____)

# Initialize MetaData: metadata
metadata = ____
编辑并运行代码