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 trialDanielle Murray
Python Development Techdegree Graduate 7,755 PointsHi could you please help me. I am struggling to get the correct output for this task. What am i missing?
Is my import wrong and my id function? Your help would be much appreciated.
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///movies.db', echo=False)
Base = declarative_base()
class Movie(Base):
__tablename__ = 'movies'
id = Column(Integer, primary_key=True)
name = Column(String)
def __init__(self, name):
self.name = name
1 Answer
Jeff Muday
Treehouse Moderator 28,720 PointsYou are correct. You just have to put things in a different order-- not your fault.
You should declare all the sqlalchemy imports on one line (shown below).
The problem is Treehouse's with the current unit-tests in the Challenge environment.
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()
class Movie(Base):
__tablename__ = 'movies'
id = Column(Integer, primary_key=True)
movie_title = Column(String)
genre = Column(String)
def __repr__(self):
return f"<Movie(movie_title={self.movie_title} genre={self.genre}>"