Example #1
0
 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()
Example #2
0
 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()
Example #3
0
 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()
Example #4
0
 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()
Example #5
0
File: main.py Project: fr4nt1x/eat
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()
Example #6
0
 def add(self):
     session.add(self)
     session.commit()
Example #7
0
 def query_update(self,table,id,update):
     data = session.query(table).filter(table.id==id).update(update)
     session.commit()
Example #8
0
File: main.py Project: fr4nt1x/eat
def addMeal(day,name,kcal,price=None):
    session.add(Meal(day= day, name=name, kcal = kcal,price=price))
    session.commit()
Example #9
0
 def query_update(self, table, id, update):
     data = session.query(table).filter(table.id == id).update(update)
     session.commit()