Added a query for minimum daily temperature and separated out the date. I started adding some code to eventually do error logging which I still need to research some more.
import datetime
import time
import MySQLdb
from tkinter import *
from tkinter.ttk import *
import logging
log = logging.getLogger("pylearn-day5")
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s',
filename='pylearn.log',
filemode='w')
log.info("Starting program")
window =Tk()
window.title("Pylearn Day 5")
window.geometry('1024x768')
lbl = Label(window, text="day 5", font=("Arial Bold", 50))
lbl.pack()
lbl1 = Label(window, text="label 1", font=("Arial Bold", 30))
lbl1.pack()
lbl2 = Label(window, text="label 2", font=("Arial Bold", 30))
lbl2.pack()
querydate = str(datetime.date.today())
def clicked2():
db = MySQLdb.connect("192.168.1.200", "pidata", "Rasp!data99", "home_data")
cursor = db.cursor()
sqlcmd = "select min(temp) from temperatures where tempTime like '" + querydate + "%' and location like 'RearDeck';"
cursor.execute(sqlcmd)
row = cursor.fetchone()
lbl.configure(text= querydate, font=("Arial Bold", 24))
lbl1.configure(text= " Min Temp " + str(row[0]), font=("Arial Bold", 24))
sqlcmd = "select max(temp) from temperatures where tempTime like '" + querydate + "%' and location like 'RearDeck';"
cursor.execute(sqlcmd)
row = cursor.fetchone()
lbl2.configure(text= " Max Temp " + str(row[0]), font=("Arial Bold", 24))
db.close()
button_2 = Button(window, text="Click for max temp", command=clicked2)
button_2.pack()
window.mainloop()