def delete_rel(self, noteid, tag): t = tag.first() session.query(Relate).filter( and_(Relate.marknoteid == noteid, Relate.tagid == t.id)).delete() session.commit() self.query_update(Tag, t.id, {'count': t.count - 1}) if t.count <= 0: tag.delete() session.commit()
def delete_rel(self,noteid,tag): t = tag.first() session.query(Relate).filter(and_(Relate.marknoteid==noteid, Relate.tagid==t.id)).delete() session.commit() self.query_update(Tag,t.id,{'count':t.count-1}) if t.count <= 0: tag.delete() session.commit()
def delete(self,id): note = self.query_byid(MarkNote,id) tags = {} for t in note.first().tags.split(','): if t != '': tags[t] = t for t in tags.keys(): print("tag:"+t) tag = self.query_bytitle(Tag,t) self.delete_rel(id,tag) note.delete() session.commit()
def delete(self, id): note = self.query_byid(MarkNote, id) tags = {} for t in note.first().tags.split(','): if t != '': tags[t] = t for t in tags.keys(): print("tag:" + t) tag = self.query_bytitle(Tag, t) self.delete_rel(id, tag) note.delete() session.commit()
def getCurrentDay(): lastDay = getLastDay() oneDay = timedelta(days=1) if (lastDay!= None): while (lastDay.dateofconsum != date.today()): lastDay=Day(dateofconsum=lastDay.dateofconsum+oneDay) session.add(lastDay) print(lastDay.dateofconsum) else: lastDay=Day(dateofconsum=date.today()) session.add(lastDay) print(lastDay.dateofconsum) session.commit() return getLastDay()
def add(self): session.add(self) session.commit()
def query_update(self,table,id,update): data = session.query(table).filter(table.id==id).update(update) session.commit()
def addMeal(day,name,kcal,price=None): session.add(Meal(day= day, name=name, kcal = kcal,price=price)) session.commit()
def query_update(self, table, id, update): data = session.query(table).filter(table.id == id).update(update) session.commit()