API

Section 1 | Section 2 | Section 3 | Endpoints | API-Documentation | Directory Tree | TechStack | Task Details

1. Environment setup and data loading.

Refer Section1.txt file for the desired deliverables.

Remarks:

  • It is observed that appending the following in my.cnf of MySQL installation will enable smooth flow of the delivered solution. (On Ubuntu 20.x found at /etc/mysql/my.cnf).
[mysqld]
secure-file-priv=""
sql-mode=""

2. Working with data and SQL

Refer Section2.txt file for the desired deliverables.

3. RESTful API - Python Flask and SQL Alchemy.

Quickstart with Pipenv:

Installation:

MacOS:

$ brew install pipenv

Debian:

$ sudo apt install pipenv

Windows:

  • Run Windows Power Shell as Administrator.

  • Run the following command in Power Shell.

    pip install pipenv
  • Excute the following command to set the path. (Replace <user_name> with your user name)

set PATH=%PATH%;set PATH=%PATH%;'c:\users\<user_name>\appdata\local\programs\python\python36-32\Scripts'

Issues? Try Official Documentation.

Usage:

# Activate venv
$ pipenv shell

# Install dependencies
$ pipenv install

# Run Server (http://localhst:5000)
python app.py

Known issues with python3.x:

It is observed that mysqlclient will fail to install through pipenv when using python3.x. This could be resolved using the following:

$ sudo apt-get install python3.7-dev libmysqlclient-dev libssl-dev
$ pipenv install

API Documentation

The following RESTful API implements CURD operations on Northwind dataset. A detailed documentation is avaiable here.

Endpoints

  • GET products

  • GET product/:ProductID

  • GET customers

  • GET customer/:CustomerID

  • GET orderhistory/:CustomerID

  • POST product/add

  • POST customer/add

  • PUT product/update/:ProductID

  • PUT customer/update/:CustomerID

  • DELETE product/remove/:ProductID

  • DELETE customer/remove/:CustomerID

Directory Tree:

.
├── API Documentation HTML
│   ├── API Documentation.html
...
├── app.py
├── extras
...
├── Pipfile
├── Pipfile.lock
├── README.md
├── Section1.txt
└── Section2.txt

9 directories, 44 files

License:

CC-BY-SA-04.