I'm trying to get information from a database I have. But everytime I search it says there is nothing that follows the query. This is what I have.
import datetime
import MySQLdb
db = MySQLdb.connect(user='root', passwd='', host='localhost', db = 'data') or die ('Error while connecting')
cursor = db.cursor()
sqlread = "SELECT * FROM humidity WHERE Date_Hour BETWEEN %s AND %s"
ts1 = ('%s/%s/%s 07:00:00') % (now.year, now.month, now.day)
ts2 = ('%s/%s/%s 03:00:00') % (now.year, now.month, now.day+1)
tsdata = (ts1,ts2)
cursor.excecute(sqlread,tsdata)
db.commit()
result = cursor.fetchall()
print result
Therefore, the results is 0. But I made the same search on phpMyAdmin and it worked. What I'm doing wrong?
UPDATE:
Here is my result as Jason commented.
However, I think Jason is right. I'm doing a GUI that make some charts. And I have 2 windows. One is making a graph with an animation using matplotlib, the program make the graphics with new data that is recolected from the database, so it is always asking. The other window just make one query but it doesn't work, so it could be possible because I'm asking "twice"?.