Exemple #1
0
 def update(self, attr, value):
     try:
         self.__setattr__(attr, value)
         dbSession.commit()
         return 1
     except Exception as e:
         dbSession.rollback()
         print('DB update', e)
         return None
Exemple #2
0
 def delete_all(obj_list):
     try:
         [dbSession.delete(i) for i in obj_list]
         dbSession.commit()
         return 1
     except Exception as e:
         dbSession.rollback()
         print(e)
         return None
Exemple #3
0
 def save_all(obj_list):
     try:
         dbSession.add_all(obj_list)
         dbSession.commit()
         return len(obj_list)
     except Exception as e:
         dbSession.rollback()
         print(e)
         return None
Exemple #4
0
 def delete(self):
     try:
         dbSession.delete(self)
         dbSession.commit()
         return 1
     except Exception as e:
         dbSession.rollback()
         print(e)
         return None
Exemple #5
0
 def save(self):
     try:
         dbSession.add(self)  # self实例化对象代表就是u对象
         dbSession.commit()
         return 1
     except Exception as e:
         dbSession.rollback()
         print(e)
         return None