fetch and store historical data in mysql data base