Python Flask API with SQLALCHEMY integration

Table of contents

Step 1: I fork this Repository

Step 2: I check if the fork Repository is now save on my repository

Step 3: Make a folder where we save the application

Step 4: Open the command prompt and go to that folder using cd and dir commands

Step 5: Clone your fork repository using this command

Step 6: Go to your clone repository folder using this commands

Step 7: Create a virtual environment using this command

Step 8: Activate the virtual environment using this command

Step 9: Install all the dependencies from the requirements.txt using this command

Step 10: Open the application in any ide or text editor you want or using vs code and use this command to open it from the terminal

Step 11: Now create a new database in your aiven account and name it whatever you like

Step 12: Now create .env file and add this secret keys inside it and don’t forget to add the needed information to that secret keys from you aiven cloud database

Step 13: Now copy your CA certificate from your aiven account and paste it to the app/certs/ca.pem

Step 14: Now go back to your command prompt and run flask db upgrade

Step 15: Now go to your mysql database and check if the table is now created

Step 16: Now run the application using python run.py command

Step 17: Now go the postman app login your account make a new collection and rename it to python-flask-api-sql-alchemy and add a new request and rename it to Create User use POST method and add this link 127.0.0.1:5000/users and go to Body and raw and add this json data use JSON and save this will create a new user to your aiven database

Step 18: Now send the request and if you get a response like this it means now that the data is now created in your aiven database

Step 19: Now open your aiven database cloud in your mysql database and check if the data is now created inside the table

Step 20: Now you can add more data if you want

Step 21: Now check again if the data is not created inside the table

Step 23: Now send the request and if you get the json data like this it means we can get the user by it’s id successfully

https://github.com/BrandonLCanete/flask-api-with-mysql.git

Github Repository Origin

https://github.com/thirdygayares/flask-api-with-mysql.git