def search_day():

    db = DataBase()
    qry = "SELECT days from events ORDER BY days"
    data = db.show_data(qry)
    my_data = []
    for i in data:
        my_data.append(i[0])
    print(my_data)
    print(binary_search(my_data, 'Saturday'))
    print(binary_search(my_data, 'Monday'))
Пример #2
0
class Tododbtuesday:
    def __init__(self):
        self.db = DataBase()

    def add_item(self, time, task):
        qry = "INSERT INTO tuesday (time,task) VALUES (%s,%s)"
        values = (time, task)
        self.db.iud(qry, values)
        return True

    def show_item(self):
        qry = "SELECT * FROM tuesday"
        all_items = self.db.show_data(qry)
        return all_items

    def search_item(self, key):
        qry = "SELECT * FROM tuesday WHERE name LIKE '" + key + "%'"
        all_items = self.db.show_data(qry)
        return all_items

    def update_item(self, row, time, task):
        qry = "UPDATE tuesday SET time = %s, task = %s WHERE id = %s"
        values = (time, task, row)
        self.db.iud(qry, values)
        return True

    def delete_item(self):
        pass

    def deleter(self, row):
        qry = "DELETE FROM tuesday WHERE id=%s "
        values = (row, )
        self.db.iud(qry, values)
class Event:
    def __init__(self):
        self.db = DataBase()

    def add_item(self, days, events):
        if days == '' or events == '':
            return False
        else:
            qry = "INSERT INTO events (days,events) VALUES (%s,%s)"
            values = (days, events)
            self.db.iud(qry, values)
            return True

    def show_item(self):
        all_items = []
        try:
            qry = "SELECT * FROM events"
            all_items = self.db.show_data(qry)
            return all_items
        except Exception as abc:
            print(abc)
            return all_items

    def search_item(self, key):
        qry = "SELECT * FROM events WHERE days LIKE '" + key + "%'"
        all_items = self.db.show_data(qry)
        return all_items

    def update_item(self, row, days, events):
        try:
            qry = "UPDATE events SET days = %s, events = %s WHERE id = %s"
            values = (days, events, row)
            self.db.iud(qry, values)
            return True
        except Exception as error:
            print(error)
            return False

    def deleter(self, row):
        try:
            qry = "DELETE FROM events WHERE id=%s "
            values = (row, )
            self.db.iud(qry, values)
            return True
        except Exception as error:
            print(error)
            return False
 def __init__(self):
     self.db = DataBase()