Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python SQLAlchemy Basics Introduction to SQLAlchemy Creating a Movie Model

patrick bragg
patrick bragg
5,078 Points

idk whats wrong

I don't know whats wrong with my code tbh, it says "you should have a column named id" but i have one so im confused

models.py
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

engine = create_engine('sqlite:///movies.db', echo=False)
Base = declarative_base()
id = column(Integer, primary_key=True)
movie_title = column(String)
genre = column(String)

class Movie(Base):
    __tablename__ = "movies"

1 Answer

Rohald van Merode
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Rohald van Merode
Treehouse Staff

Hey patrick bragg πŸ‘‹

You have all the right pieces to pass this challenge, The only thing you'll want to have a look at is the placement of your lines of code. The properties of the table should be defined inside the Movie class instead of the global scope.

if you nest the lines for id, movie_title and genre in your Movie class your code should pass the challenge as expected πŸ˜„

class Movie(Base): 
    __tablename__ = "movies"
    id = Column(Integer, primary_key=True)
    movie_title = Column(String)
    genre = Column(String)

Hope this helps! πŸ™‚

patrick bragg
patrick bragg
5,078 Points

thank you for the help, i tried that at one point and it didnt work but then i copied the lines of code you gave and it worked for some reason, i think it might have to do with the fact that i forgot to capitalize the column but it may have been a different spelling mistake. either way i figured it out thanks