Ejemplo n.º 1
0
 def update_post(cls, post_id, update_data, old_post):
     if not update_data:
         return old_post
     update = False
     for key, value in update_data.items():
         if value != old_post[key]:
             update = True
     if not update:
         return old_post
     update_statement = ''
     data = tuple()
     for key, item in update_data.items():
         old_post[key] = item
         update_statement += '{0} = %s, '.format(key)
         data += item,
     update_statement += "is_edited = true"
     old_post['isEdited'] = True
     sql = """
                 UPDATE {tbl_name} SET {update_statement} WHERE id = {post_id}
             """.format_map({
         'tbl_name': cls.tbl_name,
         'update_statement': update_statement,
         'post_id': post_id,
     })
     DbConnector.execute_set(sql, data)
     return old_post
Ejemplo n.º 2
0
 def update_thread(cls, thread_id, update_data, bedore_update):
     if not update_data:
         return bedore_update
     update_statement = ''
     data = tuple()
     for key, item in update_data.items():
         bedore_update[key] = item
         update_statement += '{0} = %s, '.format(key)
         data += item,
     update_statement = update_statement[:-2]
     sql = """
         UPDATE {tbl_name} SET {update_statement} WHERE id = {thread_id}
     """.format_map({
         'tbl_name': cls.tbl_name,
         'update_statement': update_statement,
         'thread_id': thread_id,
     })
     DbConnector.execute_set(sql, data)
     return bedore_update