def getResponse(delay):
    print "Iniciando Captura de Dados => " + timestamp()
    saveFile("Iniciando Captura de Dados => " + timestamp())
    count = True
    while count == True:
        fio = ForecastIO.ForecastIO(apikey, units=ForecastIO.ForecastIO.UNITS_AUTO, lang=ForecastIO.ForecastIO.LANG_PORTUGUESE, latitude=Quixada[0], longitude=Quixada[1])
        time.sleep(delay)
        if fio.has_currently() is True:
            currently = FIOCurrently.FIOCurrently(fio)
            print "Captura => " + timestamp()
            saveFile("Captura => " + timestamp())

            t = datetime.datetime.fromtimestamp(currently.time).strftime('%Y-%m-%d %H:%M:%S')
            summary = currently.summary
            icon = currently.icon
            precipIntensity = currently.precipIntensity
            precipProbability = currently.precipProbability
            precipType = currently.precipType
            temperature = currently.temperature
            apparentTemperature = currently.apparentTemperature
            humidity = currently.humidity
            windSpeed = currently.windSpeed
            cloudCover = currently.cloudCover
            pressure = currently.pressure
            ozone = currently.ozone

            query =  "INSERT INTO currently (createdat, summary, icon, precip_intensity, precip_probability, precip_type, temperature, apparent_temperature, humidity, wind_speed, cloud_cover, pressure, ozone) VALUES (%s, %s, %s, %f, %f, %s, %f, %f, %f, %f, %f, %f, %f)" %('"'+t+'"','"'+summary+'"','"'+icon+'"',precipIntensity,precipProbability,'"'+precipType+'"', temperature, apparentTemperature, humidity,windSpeed,cloudCover,pressure ,ozone)
            print query
            print "\n"
            WeatherDb.execQuery(query)
        else:
            print 'Não possui Informações'
            saveFile('Não possui Informações')
 def currently(self):
     currently = WeatherDb.select("SELECT * FROM currently WHERE id = (SELECT MAX(id) FROM currently)")
     for row in currently:
         idcurrently = row[0]
         createdat = row[1]
         summary = row[2]
         icon = row[3]
         precipIntensity = row[4]
         precipProbability = row[5]
         precipType = row[6]
         temperature = row[7]
         apparentTemperature = row[8]
         humidity = row[9]
         windSpeed = row[10]
         cloudCover = row[11]
         pressure = row[12]
         ozone = row[13]
         #
         weather = json.dumps({'id':idcurrently,'createdat':createdat,'summary':summary,'icon':icon,'precip_intensity':precipIntensity,'precip_probability':precipProbability,'precip_type':precipType,'temperature':temperature,'apparent_temperature':apparentTemperature,'humidity':humidity,'wind_speed':windSpeed,'cloud_cover':cloudCover,'pressure':pressure,'ozone':ozone})
     return weather