SHARE
TWEET

Untitled

a guest Jan 24th, 2020 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @app.route('/upsala', methods=['POST'])
  2. def update_sala():
  3.     conn = pymysql.connect()
  4.     cursor = conn.cursor()
  5.     try:
  6.         _json = request.json
  7.         _id_salas = _json['id_salas']
  8.         _id_campus = _json['id_campus']
  9.         _numero = _json['numero']
  10.         if _id_salas and _id_campus and _numero and request.method == 'POST':
  11.             sql = "UPDATE salas SET id_campus=%s, numero=%s WHERE id_salas=%s"
  12.             data = (_id_salas, _id_campus, _numero)
  13.             cursor.execute(sql, data)
  14.             conn.commit()
  15.             resp = jsonify('User updated successfully!')
  16.             resp.status_code = 200
  17.             return resp
  18.         else:
  19.             return not_found()
  20.     except Exception as e:
  21.         print(e)
  22.     finally:
  23.         cursor.close()
  24.         conn.close()
  25.         return '200-OK'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top