I am creating a stock price database with Sqlite3 python library. But my code is taking ages to run, not sure why it is slow. Any idea how I can speed it up? Am I doing something wrong?
I am using Python 3.x, Anaconda
import pandas as pd
from googlefinance.client import get_price_data, get_prices_data, get_prices_time_data
import sqlite3
db = sqlite3.connect('database.db')
c = db.cursor()
param = {'q':'MMM', 'i':"86400",'x':"NYSE",'p':"25Y"}
end_of_day = pd.DataFrame(get_price_data(param))
end_of_day['Time']=end_of_day.index
count= len(end_of_day['Time'])
c.execute('CREATE TABLE IF NOT EXISTS MMM(date,open,high,low,close,volume)')
for i in range(0,count):
c.execute('INSERT INTO MMM(date,open,high,low,close,volume) VALUES(?,?,?,?,?,?)',
(str(end_of_day.iloc[i][5]),str(end_of_day.iloc[i][0]),str(end_of_day.iloc[i][1]),
str(end_of_day.iloc[i][2]),str(end_of_day.iloc[i][3]),str(end_of_day.iloc[i][4])))
db.commit()
c.close()
db.close()
count?