I am saving datetime and temperature values into a database and I am trying to get the last temperature and datetime value.
I tried using the code described in the link below:
And wrote this:
query1 = db.session.query.order_by(temperaturelog.dTime.desc()).first()
query2 = db.session.query.order_by(temperaturelog.Temperature.desc()).first()
data.append(query1)
data.append(query2)
return data
However, I got errors such as:
NameError: name 'session' is not defined
Do I need to replace 'session' with something else? I tried using the variable used in the creation of the SQLAlchemy(app) and tried replacing it with my class name for the database which is temperaturelog.
All help appreciated,
Thanks.