import pandas as pd
import numpy as np
import sqlite3
import time

start = time.time()

data = pd.read_excel("data.xlsx")
df = pd.DataFrame()

years = []
months = []
level2s = []
level3s = []
skus = []
quantities = []
revenues = []
costs = []
descriptions = []

for index,row in data.iterrows():
    if type(row["FiscalYearMonth"]) == str:
        years.append(int(row["FiscalYearMonth"][0:4]))
        months.append(int(row["FiscalYearMonth"][5:]))
        level2s.append(row["Level2"])
        level3s.append(row["Level3"])
        skus.append(row["MaterialEntered"])
        quantities.append(int(row["Quantity"]))
        revenues.append(row["SalesRevenue"])
        costs.append(row["CostOfGoodsSold"])
        descriptions.append(row["ProductDescription"])


df["year"] = years
df["month"] = months
df["level2"] = level2s
df["level3"] = level3s
df["sku"] = skus
df["quantity"] = quantities
df["revenue"] = revenues
df["cost"] = costs
df["description"] = descriptions

conn = sqlite3.connect("data.db")
df.to_sql("data", conn, if_exists='replace')

end = time.time()

print(end-start)