def delete(cls, id): sql = 'delete from movie_order where id=%s' try: store.execute(sql, id) store.commit() except IntegrityError: store.rollback() return False return True
def get(cls, id): sql = ('select id, type_id, order_id, price from movie_order ' 'where id=%s') rs = store.execute(sql, id) cls.clear_mc(id) return cls(*rs[0]) if rs else ''
def update_price(self, price): sql = 'update movie_order set price=%s where id=%s' updated = store.execute(sql, (price, self.id)) if updated: store.commit() mc_delete(self.MC_KEY % self.id) return updated