Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Gabriel Guerra
Gabriel Guerra
Data Analysis Techdegree Student 3,814 Points

Sqlalchemy Movie challenge

HI there Any idea why I don't pass this challenge, I get the error message: 'You should have a variable called new_movie that creates an instance of Movie().'


from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

engine = create_engine(sqlite:///movies.db, echo=False)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()

class Movie(Base):
    __tablename__ = movies

    id = Column(Integer, primary_key=True)
    movie_title = Column(String)
    genre = Column(String)

    def __repr__(self):
        return f'<User(movie_title={self.movie_title}, genre={self.genre})>'

if __name__ == "__main__":

    new_movie = Movie(movie_title = "Lord of the rings", genre = "Fantasy")
Steven Parker
Steven Parker
221,323 Points

Can you provide a link to the challenge page?

2 Answers

Steven Parker
Steven Parker
221,323 Points

The challenge seems to be a stickler for "best practice" syntax, and apparently doesn't like the spaces around the equal signs where named arguments are being passed.

Also, it looks like you did a few extra things like adding a "__repr__" method to the Movie, a call to a create_all method, and adding a test for "__main__". As a general rule to avoid confusing the challenge checker, do only what the instructions ask for.