def renameItem(tableName,itemID_parent,itemNum): if itemNum == -1: return elif tableName=="tasks_list" and itemNum == 0: return if itemID_parent==None: itemID=itemNum else: itemID=getItemID(tableName,itemID_parent,itemNum) oldName = getItemName(tableName,itemID) idName = getIDName(tableName) idName_parent = getParentIDName(tableName) columnName = getColumnName(tableName) print(uInput.promptNew) newItemName = uInput.getName(tableName) if tableName == "subtasks_2021": cursor.execute("UPDATE {tableName} SET {columnName} = \"{newItemName}\" WHERE {idName_parent} = \"{itemID_parent}\" AND {columnName} = \"{oldName}\"".format(tableName=tableName,columnName=columnName,newItemName=newItemName,oldName=oldName,idName_parent=idName_parent,itemID_parent=itemID_parent)) db.commit() elif itemExistsByName(tableName,itemID_parent,newItemName): print(uInput.promptTaskExists) else: cursor.execute("UPDATE {tableName} SET {columnName} = \"{newItemName}\" WHERE {idName} = \"{itemID}\"".format(tableName=tableName,columnName=columnName,newItemName=newItemName,idName=idName,itemID=itemID)) db.commit()
def addLogWithRef(tableName,itemID_parent,index): if index == -1: return idName_parent = getParentIDName(tableName) columnName = getColumnName(tableName) item = getItemName(tableName,index) duration = uInput.getDuration() date = uInput.getDate(0) status = uInput.getStatus() duedate = uInput.getDue() cursor.execute("INSERT INTO {tableName} ({idName_parent},{columnName},duration,timestamp,status,duedate) VALUES (\"{itemID_parent}\",\"{item}\",{duration},\"{date}\",\"{status}\",\"{duedate}\")".format(tableName=tableName,idName_parent=idName_parent,columnName=columnName,itemID_parent=itemID_parent,item=item,duration=duration,date=date,status=status,duedate=duedate)) db.commit() print("Item successfully created.") menu.back()
def createItem(tableName,itemID_parent,allowDup): print(uInput.promptNew) item = uInput.getName(tableName) if itemExistsByName(tableName,itemID_parent,item) and allowDup==False: print("Item already exists.") else: idName_parent = getParentIDName(tableName) columnName = getColumnName(tableName) if idName_parent==None: cursor.execute("INSERT INTO {tableName} ({columnName}) VALUES (\"{item}\")".format(tableName=tableName,columnName=columnName,item=item)) elif tableName=="main_tasks": cursor.execute("INSERT INTO {tableName} ({columnName},{idName_parent}) VALUES (\"{item}\",\"{itemID_parent}\")".format(tableName=tableName,columnName=columnName,idName_parent=idName_parent,item=item,itemID_parent=itemID_parent)) elif tableName=="subtasks_2021": duration = uInput.getDuration() date = uInput.getDate(0) status = uInput.getStatus() duedate = uInput.getDue() cursor.execute("INSERT INTO {tableName} ({idName_parent},{columnName},duration,timestamp,status,duedate) VALUES (\"{itemID_parent}\",\"{item}\",{duration},\"{date}\",\"{status}\",\"{duedate}\")".format(tableName=tableName,idName_parent=idName_parent,columnName=columnName,itemID_parent=itemID_parent,item=item,duration=duration,date=date,status=status,duedate=duedate)) db.commit() print("Item successfully created.") menu.back()
def deleteItem(tableName,itemID_parent,itemNum): if itemNum == -1: return elif tableName=="tasks_list" and itemNum == 0: return if itemID_parent==None: itemID = itemNum else: itemID = getItemID(tableName,itemID_parent,itemNum) idName = getIDName(tableName) cursor.execute("DELETE FROM {tableName} WHERE {idName} = \"{itemID}\"".format(tableName=tableName,idName=idName,itemID=itemID)) if tableName=="tasks_list": resetPriKey("subtasks_2021") resetPriKey("main_tasks") resetPriKey("tasks_list") elif tableName=="main_tasks": resetPriKey("subtasks_2021") resetPriKey("main_tasks") elif tableName=="subtasks_2021": resetPriKey("subtasks_2021") db.commit() print("Item successfully deleted.") menu.back()
def updateItem(tableName,columnName,itemUpdate,idName,itemID): cursor.execute("UPDATE {tableName} SET {columnName} = \"{itemUpdate}\" WHERE {idName} = \"{itemID}\"".format(tableName=tableName,columnName=columnName,itemUpdate=itemUpdate,idName=idName,itemID=itemID)) db.commit()