-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateDb_noEmail.py
More file actions
executable file
·50 lines (37 loc) · 1.35 KB
/
Copy pathupdateDb_noEmail.py
File metadata and controls
executable file
·50 lines (37 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python3
import sqlite3
import datetime as dt
from datetime import datetime, timedelta
import yagmail
conn = sqlite3.connect('database.db')
plants = conn.execute('SELECT * FROM plants').fetchall()
garden = conn.execute('SELECT * FROM garden').fetchall()
today = dt.datetime.now()
temp = today.strftime('%Y-%m-%d')
thirsty = ''
email_list = "emailAddresses.txt"
thirsty_boi = "/home/danny/scripts/plantTracker/venv/plantFlask/static/thirstyBoy.png"
if plants:
for item in plants:
lastWatered = dt.datetime.strptime(item[2], '%Y-%m-%d')
delta = int(item[3])
daysSince = today - lastWatered
daysMod = daysSince.days
name = item[1]
timeLeft = delta - daysMod
if daysMod >= delta:
thirsty += str(item[1]) + """ bby says, "Please water me! It's been """ + str(daysMod) + " whole days!\"\n\n"
conn.execute('UPDATE plants SET remaining = ? WHERE name = ?', (timeLeft, name))
if garden:
for item in garden:
lastWatered = dt.datetime.strptime(item[2], '%Y-%m-%d')
delta = int(item[3])
daysSince = today - lastWatered
daysMod = daysSince.days
name = item[1]
timeLeft = delta - daysMod
if daysMod >= delta:
thirsty += str(item[1]) + """ bby says, "Please water me! It's been """ + str(daysMod) + " whole days!\"\n\n"
conn.execute('UPDATE garden SET remaining = ? WHERE name = ?', (timeLeft, name))
conn.commit()
conn.close()