I am trying to make a notification depending on the current date, and I have a date list from the database, so when the current date matches any date from the date list so the GUI will display a notification message box that includes that date and some other info from the same row that has the date that matches the current date.
Problem: How to select and fetch values from the database, by depending on the date column so I can insert the date and the other values from that specific date, in the notification message box.
What I have tried:
# Importing
DateEntry
from
tkcalendar
to store dates in the database:
import datetime
from tkcalendar import DateEntry,Calendar
from datetime import datetime,timedelta
self.buying_registration_Date_E = DateEntry(self.buying_payment_page,justify="right", bd=3, width=35, selectmode='day',headersbackground="#487FB9",headersforeground="#FFFFFF", date_pattern='dd-mm-yyyy',textvariable=self.buying_registration_Date_var)
code: #making the date list by selecting registration_check_date from DB
self.buyingrigstrationdates = []
self.buying_registrationdates=self.cursorObj.execute
('SELECT registration_check_date, car_type FROM
buying_rigistration_date order by
registration_check_date')
self.buying_registrationdates_output=self.cursorObj.
fetchall()
for t in self.buying_registrationdates_output:
for self.buying_registrationdates_output in t:
self.buyingrigstrationdates.append
(self.buying_registrationdates_output)
self.con.commit()
date = datetime.now()
now = date.strftime('%d-%m-%Y')
print(now)
#Trying to select the values from a row where is there the current date in it, but it doesn't work and I got an empty list.
if now in self.buyingrigstrationdates:
self.dateinfo = self.cursorObj.execute("SELECT *
FROM buying_rigistration_date WHERE
strftime('%Y',registration_check_date) =
strftime('%Y','now')")
self.dateinfo_fetch = self.cursorObj.fetchall()
messagebox.showinfo("rigistration",
f"Rigistration date{self.dateinfo_fetch}")