English subtitles

← Give that App a Backend - Intro to Relational Databases

Get Embed Code
4 Languages

Showing Revision 4 created 05/24/2016 by Udacity Robot.

  1. So, here we are in the text
    editor working on forum.py.
  2. We've got some HTML down here, and we've
    got some web server code down here,
  3. and back up at the top it looks like
    there's actually another module,
  4. forumdb, for the database code.
  5. So if we look over at forumDB.py,
  6. we'll actually see rather
    a lack of database code.
  7. It looks like we're currently using
    just a Python list to store the posts.
  8. No wonder they went away when
    we restarted the server.
  9. So this AddPost function,
    inserts a topple into our database list.
  10. And the GetAllPosts function, transforms
    the list into a list of dictionaries.
  11. Where the content key
    points to the post content.
  12. And the time key points to
    the time it was posted.
  13. Over in forum.py,
    if we look in the view function,
  14. we'll see where
    forumdb.GetAllPosts is called.
  15. And then down in the post function,
    we'll see where AddPost is called.
  16. We don't need to edit any
    of the forum.py code,
  17. because everything that talks about
    the database is over in forum.db.
  18. So what we need to do is change
    this database code up here,
  19. to actually use a real database.
  20. So on the next page,
    you're going to do exactly that.