Connect to a Production-ready Database
Let’s learn how to connect to the database of a production-ready system.
Stop the docker
Before we start changing the code of the application, we have to tear down the system that’s running by executing the command below:
$ python3 manage.py compose down
/*
Stopping production_web_1 ... done
Stopping production_nginx_1 ... done
Stopping production_db_1 ... done
Removing production_web_1 ... done
Removing production_nginx_1 ... done
Removing production_db_1 ... done
Removing network production_default
*/
Changes in the application
Thanks to the common interface between repositories, moving from the memory-based MemRepo
to PostgresRepo
is very simple. Because the external database won’t contain any data initially, the response of the use case will be empty.
First of all, let’s move the application to the PostgreSQL repository. The new version of the endpoint is as follows:
Get hands-on with 1400+ tech skills courses.