Online Reatil Data
Online Reatil Data
In [1]:
import pandas as pd
from flask import Flask
import pymysql
Flask
In [2]:
app = Flask(__name__)
df=pd.read_excel('Online Retail.xlsx')
df.head()
Out[3]:
2010-12-01 United
1 536365 71053 WHITE METAL LANTERN 6 3.39 17850.0
08:26:00 Kingdom
2010-12-01 United
4 536365 84029E RED WOOLLY HOTTIE WHITE HEART. 6 3.39 17850.0
08:26:00 Kingdom
In [4]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 541909 entries, 0 to 541908
Data columns (total 8 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 InvoiceNo 541909 non-null object
1 StockCode 541909 non-null object
2 Description 540455 non-null object
3 Quantity 541909 non-null int64
4 InvoiceDate 541909 non-null datetime64[ns]
5 UnitPrice 541909 non-null float64
6 CustomerID 406829 non-null float64
7 Country 541909 non-null object
dtypes: datetime64[ns](1), float64(2), int64(1), object(4)
memory usage: 33.1+ MB
United
1 536365 71053 WHITE METAL LANTERN 6 2010-12-01 3.39 17850.0
Kingdom
United
2 536365 84406B CREAM CUPID HEARTS COAT HANGER 8 2010-12-01 2.75 17850.0
Kingdom
United
4 536365 84029E RED WOOLLY HOTTIE WHITE HEART. 6 2010-12-01 3.39 17850.0
Kingdom
API
API
In [9]:
app = Flask(__name__)
# MySQL Configuration
db_config = {
'host': 'localhost',
'user': 'root',
'password': '050501@Aks',
'database': 'akashdb',
}
@app.route('/api/data', methods=['GET'])
def get_users():
try:
# Execute a simple query to retrieve users from the table
cursor.execute("SELECT * FROM data where CustomerID=17850 limit 20")
users = cursor.fetchall()
return user_list
except Exception as e:
return str(e)
if __name__ == '__main__':
app.run(debug=False)
In [10]:
# Link : http://127.0.0.1:5000/api/data