Was working just fine, suddenly I stopped seeing the return msg in the terminal about “data being graphed successfully”. I can still see the data was sent to the server by checking the website(plotly) but now it doesn’t update. Basically i had While(1) statement to cycle through code but now it seems it only posts once even if the loop is running and no server msg for “Success”. I am running this on Raspberry Pi. If anything was recently changed on the server side please let me know!
import plotly.plotly as py
import time
import os
import datetime
import MySQLdb
from plotly.graph_objs import *
# Connect to mysql
db=MySQLdb.connect("localhost","zikmir","gforce","temp_database")
cursor=db.cursor()
while (1):
py.sign_in('zikmir','V5AVz4qgD21G7xxxxxx')
cursor.execute ("SELECT MAX(id) from time_temp")
xrow = cursor.fetchone()
maxID = xrow[0] # will give last id in db
startID = (maxID - 2900) # start id from last 24 hours
startID = str (startID)
cursor.execute("SELECT time, temp FROM time_temp WHERE id >='" + startID + "'")
rows = cursor.fetchall() # this is tulip
x_axis =[]
y_axis =[]
for row in rows:
x_axis.append(row[0])
y_axis.append(row[1])
trace0 = Scatter(x=x_axis,y=y_axis)
data = Data([trace0])
py.plot(data, filename = 'basic-line', auto_open=False)
print "Done"
time.sleep(300)