title: Should we close msyql connection in wsgi flask deployment?
body: <p>I follow the flask_mysql document but why it does not close the mysql connection. Currently, I deploy flask with apache wsgi, but i do not sure whether we should close the connection for each request ?</p>
  
  <p>I do not close connection in my current code and nothing is error.</p>
  
  <pre><code>from flask import Flask
  from flask_mysqldb import MySQL
  
  app = Flask(__name__)
  mysql = MySQL(app)
  
  
  @app.route('/')
  def users():
      cur = mysql.connection.cursor()
      cur.execute('''SELECT user, host FROM mysql.user''')
      rv = cur.fetchall()
      return str(rv)
  
  @app.route('/update_my_row",methods=["PUT"]
  def update_my_row():
      conn = mysql.connect
      cur = mysql.cursor()
      ....update ...
      conn.commit()
      ## do we need conn.close() here , and what happen if not.
      return my_response
  
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p>Can anyone explain me  should i close the connection for each request handler or not ? Thank you.</p>