title: Trying to get data from MySQL
body: <p><strong>main.py</strong></p>
  <p><em>When I use cursor.execute.. outside of route it is working.</em></p>
  <pre><code>import mysql.connector
  from flask import Flask, render_template, request, session, redirect, url_for, make_response
  
  MySQL = mysql.connector.connect(
      user='root',
      password='password',
      host='localhost',
      database='dbname',
      use_pure=True
  )
  cursor = MySQL.cursor(prepared=True)
  
  @app.route(&quot;/bridge&quot;, methods=[&quot;POST&quot;])
  def bridge():
      if request.get_json()[&quot;for&quot;] == &quot;signUp&quot;:
          if request.get_json()[&quot;type&quot;] == &quot;existence&quot;:
  
              cursor.execute(&quot;SELECT id FROM users WHERE eMail=%s&quot;, (request.get_json()[&quot;details&quot;][&quot;eMail&quot;], ))
              print(&quot;----------------- {}&quot;.format(cursor.fetchone()))
  
  
  
      print(request.get_json()[&quot;details&quot;][&quot;eMail&quot;])
  
  
  
      return make_response(json.dumps({&quot;Res&quot;}), 200)
  
  cursor.close()
  MySQL.close()
  </code></pre>
  <p><strong>Error</strong></p>
  <p>cursor.execute(&quot;SELECT id FROM users WHERE eMail=%s&quot;, (request.get_json()[&quot;details&quot;][&quot;eMail&quot;], ))
  File &quot;C:\Users\woxro\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\mysql\connector\cursor.py&quot;, line 1186, in execute
  charset = self._connection.charset
  AttributeError: 'NoneType' object has no attribute 'charset'</p>