Use Flask AppBuilder to develop CRUD REST APIs.
Overview
For Python, when it comes to API development, we have an abundance of choices. Popular ones are Django, Flask, and FastAPI, to name a few.
In this article, let’s use Flask to build RESTful APIs to create, read, update and delete (CRUD) records in a database table. Specifically, I will use Flask + Flask AppBuilder to build the APIs in 5 minutes.
Setup
Libraries
Let’s install the flask-appbuilder
library. I also installpython-dotenv
in order to use a .env
file as my configuration file.
$ pip install flask-appbuilder python-dotenv
Using a virtualenv
will be preferred. I assume you are already familiar with Python and will not go through the steps here. For me, I prefer to use Minconda to manage all my packages.
PostgreSQL
For this example, I am going to use PostgreSQL. The docker-compose
file is shown below.
As part of the database setup, a database table called accounts
is created.
CREATE TABLE accounts (
userid SERIAL…