A RESTful API for ingesting data into a AWS RDS-MySQL database and retrieving information using GET endpoints.
This project is a RESTful API built using FastAPI that allows you to ingest data from CSV files into a MySQL database and retrieve information about employees and departments using various GET endpoints.
- FastAPI: A modern, fast web framework for building APIs.
- SQLAlchemy: A powerful Object-Relational Mapping (ORM) library.
- Amazon RDS for MySQL: A cloud-based managed relational database service provided by Amazon Web Services.
-
In the process of migration, it is essential to select a database for establishing a connection with our API. You are free to opt for a database that aligns with your familiarity and expertise. For the purpose of this guide, I will demonstrate using MySQL as the chosen database.
CREATE DATABASE your_data_base;
- Begin by navigating to the 'db.py' file to ensure that your database connection is properly configured and functioning.
- When utilizing AWS RDS for MySQL, it's crucial to conduct a thorough assessment to ensure seamless connectivity. Begin by verifying that the Public Accessibility setting is configured as 'YES'.
Subsequently, navigate to the security group settings, access the inbound rules section, and proceed to generate a new rule. This new rule should be based on the IP address retrieved from http://checkip.amazonaws.com/.
3. Define the desired schemas for your tables. In this scenario, we will be creating three tables: 'Employee,' 'Job,' and 'Department.'
- Review the POST endpoints utilized in this context, which facilitate the creation of tables and the ingestion of data into those tables. You can find these endpoints within the 'post_endpoints.py' file.
- We will be making alterations to our tables to enable the execution of specific queries through various endpoints in the future.
ALTER TABLE employee ADD CONSTRAINT fk_employee_department FOREIGN KEY (department_id) REFERENCES department (id);
ALTER TABLE employee ADD CONSTRAINT fk_employee_job FOREIGN KEY (job_id) REFERENCES job (id);
- We aspire to establish a table schema resembling the following::
- Please examine the 'get_endpoints.py' file to observe the query executions that gather valuable information, instrumental in making significant decisions for the company.
- The presentation.html file contains comprehensive information about the API, offering a deeper understanding of its functionalities and features.
To consistently verify the proper functioning of your API, utilize the following command:
uvicorn app:app --reload.
This ensures that your API is continuously monitored and any issues are promptly identified and resolved.