execute ( "UPDATE tasks SET completed=0 WHERE id=?", ( taskid ,)) self. commit () def mark_task_as_incomplete ( self, taskid ): """Mark task as uncomplete""" self. ![]() ![]() execute ( "UPDATE tasks SET completed=1 WHERE id=?", ( taskid ,)) self. Return completed_tasks, uncomplete_tasks def mark_task_as_complete ( self, taskid ): """Mark tasks as complete""" self. fetchall () # return the tasks to be added to the list when the application starts execute ( "SELECT id, task, due_date FROM tasks WHERE completed = 1" ). execute ( "SELECT id, task, due_date FROM tasks WHERE completed = 0" ). fetchall () return created_task def get_tasks ( self ): """Get all completed and uncomplete tasks""" uncomplete_tasks = self. execute ( "SELECT id, task, due_date FROM tasks WHERE task = ? and completed = 0", ( task ,)). commit () # GETTING THE LAST ENTERED ITEM SO WE CAN ADD IT TO THE TASK LISTĬreated_task = self. ![]() execute ( "INSERT INTO tasks(task, due_date, completed) VALUES(?, ?, ?)", ( task, due_date, 0 )) self. commit () def create_task ( self, task, due_date = None ): """Create a task""" self. execute ( "CREATE TABLE IF NOT EXISTS tasks(id integer PRIMARY KEY AUTOINCREMENT, task varchar(50) NOT NULL, due_date varchar(50), completed BOOLEAN NOT NULL CHECK (completed IN (0, 1)))" ) self. create_task_table () #create the tasks tableÄef create_task_table ( self ): """Create tasks table""" self. Import sqlite3 class Database : def _init_ ( self ): self.
0 Comments
Leave a Reply. |