This is a simple application which demostrate how to connect to a PostgreSQL DB. It's a Challenge by Bitnine.
The application returns data that was inserted in the user_table as a json_data with a status code of 200, if the call to index/
is successfull
and it throws an exception of with a status code of 500, if there is an error.
Returns
{"data":[{"age":"34","name":"Jenny","phone":null,"user_id":"3"},{"age":"29","name":"Tom","phone":"1-800-123-1234","user_id":"2"},{"age":"28","name":"John","phone":null,"user_id":"1"}],"status_code":200}
- python 3.11.0
- Flask
- PostgreSQL 15
- SQLALCHEMY
- Create a config.py file and Add the following credentials
DB_PORT =
DB_NAME = ""
DB_USER = ""
DB_PASSWORD = ""
- Clone the code from here
- install all the packages in
requirements.txt
file - Run
python postgres_driver.py