Python SQLAlchemy Basics Introduction to SQLAlchemy Creating a Movie Model

Hanwen Zhang
Hanwen Zhang
15,509 Points

Erroor:There should be a variable called engine set to create_engine(). Make sure you have 3 ///, the database named mov

There should be a variable called engine set to create_engine(). Make sure you have 3 ///, the database named movies.db, and echo set to False.

models.py
# First, import create_engine and declarative_base correctly from SQLAlchemy
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base

#Create a variable called engine and set it equal to create_engine. 
#Use create_engine to create a SQLite database called movies.db and set echo to False. 
#Next, create a variable named Base and set it equal to declarative_base. Then create the model class. 
#It should be called Movie, and it takes Base as an argument (it inherits from Base). 
#Inside of the class, set the __tablename__ to ’movies’.
engine = create_engie('sqlite:///movies.db', echo = False) 
Base = declarative_base()

class Movie(Base):
    __tablename__ = movies

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 64,074 Points

Hanwen Zhang, you are SO close. Look for the typo create_engie

The checker doesn’t like space before or after argument assignments. Use echo=False

There also seems to be an issue with the quote marks around “movie”. Notice in your post how the string “movie” isn’t the same color as the string used for create_engine?

Post back if you need more help. Good luck!!!

Hanwen Zhang
Hanwen Zhang
15,509 Points

Thank you for catching my typos