The Database

Learn how to set up SQLite Database with our application.

Let’s switch gears and move over to the server application and get a basic Flask REST service up and running. The back-end server isn’t our main focus, but at least we’ll try and point out some of the interesting code bits anyway.

Using SQLite as the database

We’ll be using a SQLite database. SQLite is a serverless, file-based database. It’s quick to set up and is included in the Python standard library, so we don’t need to install any extra libraries to use it.

Creating and accessing a database

We’ll open up a new connection anytime we need to read a database or write operations, and we won’t worry about maintaining a database connection pool. While this is certainly not considered best practice for a production server, it will work fine for our simple demo application. On the initial connection, if the database doesn’t exist, it will be created and optionally populated with some test data.

Most importantly, we’ll be seeing Python modules, which are mainly taking care of CRUD operations in the SQLite database. So, we’ll be reading through a lot of SQL code.

About the application

We’ll not find any changes to the front-end, because we are looking at changes on the back-end, which will not be visible to the user.

However, this is what the application looks like:

Get hands-on with 1400+ tech skills courses.