code: def app_update_state(app_id,state):
      
      try:
          create_at = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
          conn = get_conn()
          c = conn.cursor()
          c.execute("UPDATE app SET state='{0}',change_at='{1}' WHERE id='{2}'".format(state, create_at, app_id))
          conn.commit()
          conn.close()
          print 'UPDATE app %s state to %s succeed!' % (app_id,state)
      except Exception, e:
          raise RuntimeError( 'update app %s state to %s failed! %s' % (app_id,state,e) )
docs: update app state