def runMySQL(numberOfExecutions): print('Starting MySQL Benchmark') mysqlDB = mysql.Mysql() mySQLResults = mysqlDB.runQueries(mysqlqueries(), numberOfExecutions) mysqlDB.disconnect() print('Finished MySQL Benchmark') output.printSingleResult(mySQLResults) return mySQLResults
def runMySQL(numberOfExecutions, polygonID): print('Started MySQL Benchmark') db = mysql.Mysql() results = db.runQueries(mysqlqueries(polygonID), numberOfExecutions) db.disconnect() print('Finished MySQL Benchmark') output.printSingleResult(results) return results
def main(): # Get the sql query query_insert_station = "INSERT INTO station (sid, station_id, station_name, station_address, lat, lng, bike_stands," \ "ava_bikes,ava_stands,status,update_time) " \ "VALUES (NULL,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" query_insert_station_weather = "INSERT INTO station_weather(id,station_id,lat,lng,weather_id,temp, feels_like," \ " temp_min, temp_max, pressure, humidity, wind_speed, wind_deg, clouds, rain_1h," \ " rain_3h, snow_1h, snow_3h, update_time, sid)" \ "VALUES(NULL,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);" # Connect to the database server = depend_constant.DB_SERVER # host name user = depend_constant.DB_USER # user name password = depend_constant.DB_PASSWORD # password # Create the instance of mysql.Mysql db = mysql.Mysql(server, 3306, user, password, "dbike") # Send the query and insert into table station db.executemany(query_insert_station, insert_data2station(depend_constant.API_KEY_JCD, "dublin")) # Select the sid of station to refresh station_weather sid_query = "select s.sid, s.lat, s.lng, s.station_id " \ "from station s " \ "left join station_weather sw on s.sid = sw.sid " \ "where sw.sid is null" # Get the return data from db query sid_return = db.query(sid_query) station_weather_renew_row = 0 for sid_dict in sid_return: # Get the parameter to generate table station_weather lat_wea = sid_dict['lat'] lon_wea = sid_dict['lng'] sid_wea = sid_dict['sid'] station_id_wea = sid_dict['station_id'] # Insert into station_weather table db.executemany( query_insert_station_weather, insert_data2weather(lat_wea, lon_wea, sid_wea, station_id_wea, depend_constant.API_KEY_OW)) # Count the number of refreshed rows station_weather_renew_row += 1 # Count the number of rows station_renew_row = len( insert_data2station(depend_constant.API_KEY_JCD, "dublin"))