Currently using flask as a back end to load data, queried from a database. The front end is written in html/css.
Before I started using sqlalchemy to pull data, loading the page took no time at all (render template). But since I started involving data into it, its been taking 40s just to load.
Thoughts on how I can speed things up?
Thanks!
@app.route('/')
def hello():
#we will be taking 3 hydro generator and passing all of their information into the hydro table, including MCR, TNG, and DCR
zengine = sqlalchemy.create_engine("oracle+cx_oracle://TRN_ETMREAD:ETM*3^er6g7y@trn-primarydb.zepower.com:1522/ZEPP01")
hydro_sql = "select hub, mcr, tng, dcr from (select * from ZE_DATA.AESO_CSD_GENERATION order by DBMS_RANDOM.Value) where rownum <= 3 and hub = 'Hydro'"
hydro = pd.read_sql_query(hydro_sql, zengine)
#storing all the mcrs, tngs, and dcrs in an array
mcr = []
tng = []
dcr = []
for i in range(0, len(hydro)):
mcr.append(hydro.loc[i,'mcr'])
tng.append(hydro.loc[i,'tng'])
dcr.append(hydro.loc[i,'dcr'])
hydro_mcr1= mcr[0]
hydro_mcr2 = mcr[1]
hydro_mcr3 = mcr[2]
hydro_tng1 = tng[0]
hydro_tng2 = tng[1]
hydro_tng3 = tng[2]
hydro_dcr1 = dcr[0]
hydro_dcr2 = dcr[1]
hydro_dcr3 = dcr[2]
return render_template('tables-basic.html', hydro_mcr1=hydro_mcr1, hydro_mcr2=hydro_mcr2, hydro_mcr3=hydro_mcr3,hydro_tng1=hydro_tng1, hydro_tng2=hydro_tng2, hydro_tng3=hydro_tng3, hydro_dcr1=hydro_dcr1, hydro_dcr2=hydro_dcr2, hydro_dcr3=hydro_dcr3)
if name == 'main': app.run()
Aucun commentaire:
Enregistrer un commentaire