
Once we have our PostgreSQL database running on CloudSQL, with the flag cloudsql.iam_authentication set to on. We can now have a look at how we could create a Python FastAPI backend that connects to the database.
Let's start by creating a project folder and Python environment.
mkdir cloudsql-pg-connector
cd cloudsql-pg-connector
python3 -m venv env
source env/bin/activate
We now have our project ready for the installation of packages and coding.
Start by installing the needed packages.
pip install fastapi "cloud-sql-python-connector[pg8000]" SQLAlchemy gunicorn

Write a comment ...