Example #1
0
    def delete_todo_db(self):
        conn = self.get_connection()
        cursor = conn.cursor()
        sql_query = read_sql_file("./queries/delete_todo_db.sql")

        self.excute_queries(sql_query, cursor)

        conn.close()
Example #2
0
    def insert_sql_dump(self, filename='./queries/insert_dump.sql'):
        conn = self.get_connection()
        cursor = conn.cursor()

        sql_query = read_sql_file(filename)

        self.excute_queries(sql_query, cursor)

        conn.close()
        self.sync_with_cache()
Example #3
0
    def add_todo(self, todo):
        conn = self.get_connection()
        cursor = conn.cursor()

        sql_query = read_sql_file("./queries/add_todo.sql")
        sql_query[-1] = sql_query[-1] % (todo.content, todo.status)

        self.excute_queries(sql_query, cursor)

        conn.close()
        self.sync_with_cache()
Example #4
0
    def remove_todo(self, todo):
        conn = self.get_connection()
        cursor = conn.cursor()

        sql_query = read_sql_file("./queries/remove_todo.sql")
        sql_query[-1] = sql_query[-1] % todo.idx

        self.excute_queries(sql_query, cursor)

        conn.close()
        self.cache.delete_todo(todo)
Example #5
0
    def unmark_todo_done(self, todo):
        if todo.status == 0:
            raise Exception(str(todo.idx) + ": already doing job!")
        conn = self.get_connection()
        cursor = conn.cursor()

        sql_query = read_sql_file("./queries/unmark_todo.sql")
        sql_query[-1] = sql_query[-1] % todo.idx

        self.excute_queries(sql_query, cursor)

        conn.close()
        self.cache.toggle_status(todo)
Example #6
0
    def get_all_todo_list(self):
        conn = self.get_connection()
        cursor = conn.cursor()
        sql_query = read_sql_file("./queries/get_todo_list.sql")

        self.excute_queries(sql_query, cursor)

        result = cursor.fetchall()

        todo_list = []
        for row in result:
            todo_list.append(Todo(row[0], row[1], row[2]))

        conn.close()

        return todo_list