title: Python Flask Insert data into MySQL
body: <p>I have a registration form like this:</p>
  
  <pre><code>&lt;form action="{{url_for('app.register')}}" method="post"&gt;
              &lt;input type="text" placeholder="First Name" name="fname" required/&gt;&lt;br&gt;&lt;br&gt;
              &lt;input type="text" placeholder="Last Name" name="lname" required/&gt;&lt;br&gt;&lt;br&gt;
              &lt;input type="text" placeholder="username" name="user" required/&gt;&lt;br&gt;
              &lt;input type="password" placeholder="password" name="password" required/&gt;&lt;br&gt;
              &lt;input type="password" placeholder="confirm password" name="cpassword" required/&gt;&lt;br&gt;&lt;br&gt;
              &lt;input type="text" placeholder="Email" name="email" required/&gt;&lt;br&gt;&lt;br&gt;
              &lt;select id="soflow" name="selection" required &gt;
    &lt;option value = "Default"&gt;Select a Security Question&lt;/option&gt;
    &lt;option value = "What is your first school"&gt;What is your first school?&lt;/option&gt;
    &lt;option value = "What is the name of your first pet"&gt;What is the name of your first pet?&lt;/option&gt;
    &lt;option value = "What is your first car"&gt;What is your first car?&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;&lt;br&gt;
    &lt;input type="text" placeholder="Security Answer" name="answer" required/&gt;&lt;br&gt;
              &lt;input type="submit" value="Sign Up"&gt;
  
      &lt;/form&gt;
  </code></pre>
  
  <p>And my python code to retrieve and insert data into database like this:</p>
  
  <pre><code>db = MySQLdb.connect(host="localhost", user="root", passwd="", db="osn")
  cur = db.cursor()
  @blueprint.route('/register/', methods=['GET', 'POST'])
  def register():
      adduser()
      return render_template('reg.html')
  
  @blueprint.route('/adduser/', methods=['GET', 'POST'])
  
  def adduser():
      print("Entered")
  
      try:
          fname = request.form['fname']
          lname = request.form['lname']
          password = request.form['password']
          username = request.form['user']
          cpassword = request.form['cpassword']
          email = request.form['email']
          selection = request.form['selection']
          answer = request.form['answer']
          print fname,lname,password,username,cpassword,email,selection,answer
          cur.execute("INSERT INTO 'login'('fname','lname','username','password','email','question','answer') VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",(fname,lname,username,password,cpassword,email,selection,answer))        
          print "Registered"
      except Exception as e:
         return(str(e))
  </code></pre>
  
  <p>The problem here is it is executing upto the print statement above insert statement it does not show any error but data is not being inserted. Where have I gone wrong. Please do consider that Im new to Flask. Thanks in advance :)</p>