Teaching myself Python Day 3

avatar

I made several changes today. I noticed that the Max temperature query was looking at all of the temperatures in the database not just a single sensor. So I changed the query to just query the RearDeck sensor. I also changed the query to automatically get today's date and not hardcode the date.

pylearnday4.png

import datetime
import time
import MySQLdb
from tkinter import *
from tkinter.ttk import *

window =Tk()
window.title("Pylearn Day 4")
window.geometry('1024x768')
lbl = Label(window, text="day 4", font=("Arial Bold", 50))
lbl.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 max(temp) from temperatures where tempTime like '" + querydate + "%' and location like 'RearDeck';"
    cursor.execute(sqlcmd)
    row = cursor.fetchone()
    lbl.configure(text= querydate + "  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()



0
0
0.000
2 comments
avatar

Hello fellow @mytechtrail

Your post was upvoted with 40.43% ($0.0077) because you are an awesome member of s77assistant group.

You have earn a total of $0.9156 so far. keep it up.
Together we can achieve our goal and push STEEM to the moon.

You can increase your upvote value by increasing your collected points with one of the following ways:

  1. Delegating more SP will generate more points per day,
  2. Inviting other steemians to join our group with !invite(@membername) command,
  3. Transfering Steem/SBD

Don't forget to use EnhancedSBI functionality every day and get 3 SBI shares for every 2 STEEM you send with 2for3 memo.


At the current time my full vote worth $0.0191 but with your help this can change.
Delegating power will increase my vote worth and your reward.
50SP, 100SP, 250SP, 500SP, 1,000SP, 5,000SP, Custom Amount
Make sure you have at least 15 SP left on your account.


Visit s77assistant's daily report to stay informed about any news


s77assistant now supports his first game.
image.png


Golden Deals!!! Win amazing rewards including Legendary SteemMonster Cards, SBI Shares and STEEM
image.png

0
0
0.000