PacktPublishing / Mastering-Flask-Web-Development-Second-Edition

Mastering Flask Web Development, published by Packt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chapter 2 issue - Relationships between models with sqlalchemy

julianmoors opened this issue · comments

I have followed the code examples to the letter, but when I try to enter the following shell commands:

'>>> user = User.query.get(1)
'>>> new_post = Post('Post Title')
'>>> new_post.user_id = user.id
'>>> user.posts

instead of getting '[]' I get the following:

sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1146, "Table 'blog.post' doesn't exist")
[SQL: SELECT post.id AS post_id, post.title AS post_title, post.text AS post_text, post.publish AS post_publish, post.user_id AS post_user_id
FROM post
WHERE %(param_1)s = post.user_id]
[parameters: {'param_1': 1}]
(Background on this error at: https://sqlalche.me/e/14/f405)