title: I am trying to design a basic CRUD application using PyMySQL and getting a 'KEY ERROR'
body: <p><strong>Below is the HTML error I faced on browser, while running this app.py file:</strong> </p>
  
  <pre><code>enter werkzeug.exceptions.BadRequestKeyError
  werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
  KeyError: 'hst_address' here
  </code></pre>
  
  <p><strong>My Application code in #app.py file:</strong> </p>
  
  <pre><code>import pymysql.cursors
  from flask import Flask
  from flask import render_template, request, redirect, url_for, flash, session
  from config import Config
  import os
  
  
  app = Flask(__name__)
  app.secret_key = "super secret key"
  
  
  @app.route("/")
  def index():
      userId = verifySessionId()
      print("User id[" + str(userId) + "]")
      return render_template("index.html")
  
  
  @app.route("/home")
  def home():
      return render_template("home.html", home =True)
  
  connection = pymysql.connect(host='localhost',
                               user='root',
                               password='',
                               db='F196083B',
                               charset='utf8mb4',
                               cursorclass=pymysql.cursors.DictCursor)
  
  
  @app.route('/insert/hospital', methods = ['POST'])
  def insert_hospital():
  
      if request.method == "POST":
  
          hid = int(request.form['hid'])
          hname = request.form['hname']
          hst_address = request.form['dress']
          hst_city = request.form['hst_city']
          hstate = request.form['hstate']
          hzip = int(request.form['hzip'])
          flash("Data Inserted Successfully!", "success")
  
          cur = connection.cursor()
          cursor.execute("INSERT INTO patients (hid,hname,hst_address,hst_city,hstate,hzip) VALUES (%s, %s, %s,%s,%s,%s)", (hid,hname,hst_address,hst_city,hstate,hzip))
          # cur.execute("INSERT INTO hospital(hid, hname,hst_address,hst_city,hstate,hzip) values (%s, %s, %s, %s, %s, %s)",(hid, hname, hst_address, hst_city, hstate, hzip))
          connection.commit()
          return redirect("/hospital")
  
  @app.route('/update/hospital', methods = ['GET', 'POST'])
  def update_hospital():
      print("hi")
      if request.method == "POST":
          for key in request.form.keys():
              print(key)
          flash("Data Updated Successfully!", "success")
          hid = int(request.form['hid'])
          hname = request.form['hname']
          hst_address = request.form['hst_address']
          hst_city = request.form['hst_city']
          hstate = request.form['hstate']
          hzip = int(request.form['hzip'])
  
          cursor = connection.cursor()
  
          cur.execute("""
          UPDATE hospital 
          SET hname=%s,hst_address=%s,hst_city=%s,hstate=%s,hzip=%s 
          WHERE hid = %s
          """,(hname, hst_address, hst_city, hstate, hzip, hid))
  
          connection.commit()
      else:
          return redirect("/hospital")
  
  
  @app.route('/delete/&lt;int:row_id&gt;', methods = ['GET','POST'])
  def delete_hospital(row_id):
      cursor = connection.cursor()
      cursor.execute("DELETE FROM hospital where hid = %s", (row_id,))
      connection.commit()
      flash("Record Deleted Successfully!", "success")
      return redirect(url_for("hospital"))
  
  @app.route("/patients")
  def patient():
      sql = "SELECT * from `patient`;"
      result = {}
      with connection.cursor() as cursor:
          cursor.execute(sql)
          result = cursor.fetchall()
          record = cursor.fetchone()
  
      return render_template("patients.html", patient = result)
  
  
  if __name__ == "__main__":
  
      app.run()
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>{% include 'header.html' %}
  &lt;div class="row"&gt;
    &lt;div class="col md-12"&gt;
      &lt;h2 class="mb-4"&gt;Hospital Details:
      &lt;/h2&gt;
      &lt;a href="{{ url_for('.add_hospital_view') }}" class="btn btn-sm btn-secondary"&gt;Add Hospital&lt;/a&gt;
      &lt;p&gt;
        {% with messages = get_flashed_messages() %}
        {% if messages %}
        &lt;ul class=flashes&gt;
          {% for message in messages %}
          &lt;li&gt;{{ message }}&lt;/li&gt;
          {% endfor %}
        &lt;/ul&gt;
        {% endif %}
        {% endwith %}
      &lt;/p&gt;
      {{ table }}
      &lt;table class="table table-striped text-center"&gt;
        &lt;thead&gt;
          &lt;tr&gt;
            &lt;th&gt;Id&lt;/th&gt;
            &lt;th&gt;Name&lt;/th&gt;
            &lt;th&gt;Address&lt;/th&gt;
            &lt;th&gt;City&lt;/th&gt;
            &lt;th&gt;State&lt;/th&gt;
            &lt;th&gt;Zip&lt;/th&gt;
            &lt;th&gt;Edit&lt;/th&gt;
            &lt;th&gt;Delete&lt;/th&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
          {% for row in hospital %}
  
          &lt;tr&gt;
            &lt;td&gt;{{row.hid}}&lt;/td&gt;
            &lt;td&gt;{{row.hname}}&lt;/td&gt;
            &lt;td&gt;{{row.hst_address}}&lt;/td&gt;
            &lt;td&gt;{{row.hst_city}}&lt;/td&gt;
            &lt;td&gt;{{row.hstate}}&lt;/td&gt;
            &lt;td&gt;{{row.hzip}}&lt;/td&gt;
            &lt;td&gt;
              &lt;a href="{{ url_for('edit_view', row_id = row.hid) }}" class="btn btn-sm btn-secondary"&gt; Edit&lt;/a&gt;
  
            &lt;/td&gt;
            &lt;td&gt;
              &lt;a href="{{ url_for('delete_hospital', row_id = row.hid) }}" class="btn btn-sm btn-secondary"&gt; Delete&lt;/a&gt;
  
            &lt;/td&gt;
          &lt;/tr&gt;
          {% endfor %}
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  {% include 'footer.html'%}</code></pre>
  </div>
  </div>
  </p>
  
  <p>Everywhere this erroneous key is provided as correct key value 'hst-address' but still in my console I'm getting keys getting displayed as (using print statements in app.py file):</p>
  
  <pre><code>hi
  hid
  hname
  hst_addrress # Which is wrong it should be displayed as **'address'**
  hst_city
  hstate
  hzip
  id
  </code></pre>
  
  <p>Everywhere in my code including my database, key for address column is provided as 'hst_address'. I'm unable to track it out, where exactly I'm getting this key error from. </p>