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 trialabou93
14,319 Pointspeewee.OperationalError: no such table: post What does this mean?
i've been following along with kenneth but somehow i got this error and I'm not too sure why. i've checked and rechecked and made sure everything was right but somehow this keeps coming up.
3 Answers
Joshua Edwards
52,175 PointsIt isn't finding a table created from the model Post in your database. For the actual post model in the models page is it called
class Post(Model):
It is also possible that somehow your code just can't read the database file. I remember in one video him mentioning that you may have to try deleting the database and restarting the app to create a new database.
abou93
14,319 PointsI deleted the database did the transaction thing and eventually got it working. thanks!
Alonso Serrano
15,341 PointsThis problem came up during the course, at 2:58 of the Stream Templates video: https://teamtreehouse.com/library/build-a-social-network-with-flask/broadcasting/stream-templates The solution, as Kenneth mentioned above, might be to add the Post model to the create_tables() method in the initialize function in models.py.
def initialize():
DATABASE.connect()
DATABASE.create_tables([User, Post], safe=True)
DATABASE.close()
Also in that file, some of the code in the create_user() function was indented within a with block:
@classmethod
def create_user(cls, username, email, password, admin=False):
try:
with DATABASE.transaction():
cls.create(
username=username,
email=email,
password=generate_password_hash(password),
is_admin=admin)
except IntegrityError:
raise ValueError("User already exists")
Kenneth Love
Treehouse Guest TeacherThat error means that your database table hasn't been created. Most of the time, I get this when I forget to add the model to my create_tables()
call.
abou93
14,319 Pointsabou93
14,319 Pointswhat could i be missing? i created the new_post class. not sure what peewee means here