I use pymysql to connect mysql
from datetime import datetime
from datetime import timedelta
import pymysql
conn = pymysql.connect()#I simplified the connecting details
print("date: {}".format(db.fetchone()[0]))
print("the type of the date: {}".format(type(db.fetchone()[0])))
print("one row : {}".format(db.fetchone()))
print("one row of the type: {}".format(type(db.fetchone())))
print("the recent time: {}".format(datetime.now()))
print("the recent time of the type: {}".format(type(datetime.now())))
date: 2017-06-01 10:00:00
the type of the date: one row :
(datetime.datetime(2017, 5, 31, 17, 0), None, 31.5, 88.7, None)
one row of the type:
the recent time: 2017-06-01 18:31:04.097299
the recent time of the type:
But
while ((time - conn.cursor().fetchone()[0] != timedelta(minutes=15))):
pass
while ((time - datetime.now() != timedelta(minutes=15))):
pass
The former showed up:
TypeError: 'NoneType' object is not subscriptable
Why are't they the same type???
Update
MY table:
create table weather (
time timestamp default current_timestamp on update current_timestamp,
id smallint,
tpr float(3,1),
wet float(3,1),
uv tinyint(2),
foreign key (id) references chatbot.station(pk));