How to make a simple web api with fastapi and get data from a mysql database?

  api, fastapi, mysql, mysql-connector, python-3.x

I already have a MySql database named ‘userdb’ and a table named ‘details’ with two columns ‘username’ and ‘points’. I want to create an API on fastAPI so that a GET request can be sent as the username via the API to get the value from the ‘points’ column corresponding to the username as json.

All online resources I checked dealt with creating new tables and models with mysql and sqlalchemy, but I am trying to understand how I can build an API with fastAPI and connect it with an already existing MySQL database.

Any help or guidance would be much appreciated.

Source: Python-3x Questions