mysql-connector-python loop over cursors very slow -
i not able query mysql database using mysql-connector-python (python version 3.5). trying pull out air_temperature particular datetime range entire list of stations. first query first stn works fine, 2nd hangs forever.
import mysql.connector import datetime connection = mysql.connector.connect(host=' ', user=' ', passwd=' ', database=' ', port= ) stn_id = [‘stn_01’,’stn_02’, ’stn_03’, ’stn_04’, ’stn_05’] datetime_start = datetime.datetime(2016, 1, 1, 00, 00, 00) datetime_end = datetime.datetime(2016, 2, 1, 00, 00, 00) stn in range(0,n_stn,1): cursor = connection.cursor(buffered=true) q = """ select time_stamp, air_temperature %s time_stamp >= %s , time_stamp <= %s """ cursor.execute(q,(stn_id[stn], datetime_start, datetime_end)) temp_results = cursor.fetchall() # results cursor.close()
Comments
Post a Comment