import sqlite3 from datetime import date class SongLogging(object): def __init__(self,logfile = "logs.sqlite"): ''' Init a connector for the logging.''' self.conn = sqlite3.connect(logfile, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) self.c = self.conn.cursor() self.today = date.today() def getSunday(self): '''returns a date object containing the date of the forthcoming Sunday Monday is a 0, Sunday is a 6''' return date.fromordinal(self.today.toordinal() + 6 - (self.today.weekday())) def checkIfSundayUsed(self): ''' Query the date column of the lastUsed table to determine if any songs have been set for the coming Sunday. Return bool ''' self.c.execute("SELECT Date FROM lastUsed") return (self.getSunday(),) in self.c.fetchall() if __name__ == "__main__": logclass = SongLogging() print logclass.checkIfSundayUsed()