Exemplo n.º 1
0
 def namedays_today(self, current_date):
     current_day = current_date.day
     current_month = current_date.month
     cursor = self.db.cursor()
     sql = ("SELECT contacts.ID, contacts.FIRST_NAME, contacts.MIDDLE_NAME, contacts.LAST_NAME FROM saints" +
     " INNER JOIN nameday ON saints.ID = nameday.SAINT_ID" +
     " INNER JOIN contacts ON (nameday.NAME = contacts.FIRST_NAME OR nameday.NAME = contacts.MIDDLE_NAME)" +
     "WHERE saints.DAY =" + str(current_day) + " AND saints.MONTH = " + str(current_month))
     cursor.execute(sql)
     rows = cursor.fetchall()
     return [contact_from_row(row) for row in rows]
Exemplo n.º 2
0
 def namedays_next_month(self):
     current_date = datetime.date.today()
     cursor = self.db.cursor()
     saint_date_fragment = "date(" + str(current_date.year) + " || '-' || substr('0'||saints.month,-2) || '-' || substr('0'||saints.day,-2))" 
     sql = ("SELECT contacts.ID, contacts.FIRST_NAME, contacts.MIDDLE_NAME, contacts.LAST_NAME, contacts.BIRTHDAY FROM saints" +
     " INNER JOIN nameday ON saints.ID = nameday.SAINT_ID" +
     " INNER JOIN contacts ON (nameday.NAME = contacts.FIRST_NAME OR nameday.NAME = contacts.MIDDLE_NAME)" +
     " WHERE " + saint_date_fragment + " > date('now') " +
     " AND " + saint_date_fragment + " <= date('now', '+300 days')")
     cursor.execute(sql)
     rows = cursor.fetchall()
     return [contact_from_row(row) for row in rows]
Exemplo n.º 3
0
 def get_contact(self, contact_id):
     cursor = self.db.cursor()
     # retrives the info of the contact in the edit_contact form
     cursor.execute("SELECT * FROM contacts WHERE ID = " + contact_id)
     # fetchone returns an array representing the fields of the first row
     return contact_from_row(cursor.fetchone())
Exemplo n.º 4
0
 def get_contacts(self):
     cursor = self.db.cursor()
     cursor.execute('''SELECT * FROM contacts ORDER BY BIRTHDAY''')
     # fetchall returns an array of arrays
     rows = cursor.fetchall()
     return [contact_from_row(row) for row in rows]
Exemplo n.º 5
0
 def birthdays_today(self):
     cursor = self.db.cursor()
     sql = ("SELECT * FROM contacts WHERE strftime('%m %d', BIRTHDAY) = strftime('%m %d', 'now')")
     cursor.execute(sql)
     rows = cursor.fetchall()
     return [contact_from_row(row) for row in rows]