Exercise 7: Linking in a Database

In this lab we will link a database into our flask application. We will install SQLite and then build some basic models, linked into views.

Project work

By now you should have formed a project group, and begun discussing your ideas for the project. Your project should be register using this application. If you haven't found a group partner yet, please see your lab demonstrator.

This week, you should have your project concept worked out and be thinking about the models and views you will need to implement. Develop some wireframe mocks of what you would like to the interface to look like, and see your lab demonstrator for feedback. Consider how it will be displayed on different sized devices, and how (and why) you would expect a user to interact with it. Also consider what routes you expect your application to serve. Make some mock web requests. You can use Apiary or Postman so you can use these requests for testing later on.

Getting started with SQLite

SQLite should come with python automatically. From within your virtual environment, try the command sqlite or sqlite3. If that doesn't work you can install SQLite on your system by following the instructions here. Then work through this tutorial and make sure that you understand the basics of relational databases and SQL.

Link your database into Flask

Continue with chapter 4 and 5 of Miguel Grinberg's mega tutorial. This will link in databases, and provide some basic authentication for users.