Exercise 7: Linking in a Database

In this lab we will link a SQLite database with 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 registered 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. There are many online tools to help you with this, such as MockFlow; or you can use pen-and-paper. Consider how it will be displayed on different sized devices, as well as how (and why) you would expect a user to interact with it. Also consider what routes you expect your application to serve. Mock-up some 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. Work through this tutorial and make sure that you understand the basics of relational databases and SQL.

Link your Database with Flask

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