title: Flask Insert data into Database using MySQL
body: <p>I am trying to insert data into MYSQL database
  when I try my program I get an error "Not enough arguments for format 
  the string" at the following line.</p>
  
  <pre><code>ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB se
  rver version for the right syntax to use near '%s)' at line 1
  </code></pre>
  
  <p><strong>And my code</strong>: </p>
  
  <pre><code>from flask import Flask, render_template, request
  import mysql.connector
  
  app = Flask(__name__, static_url_path="", static_folder="static")
  
  mydb = mysql.connector.connect(
    host="localhost",
    user="root",
    password="",
    database="railway"
  )
  mycursor = mydb.cursor()
  
  @app.route('/')
  def index():
      return render_template('index.html')
  
  @app.route('/store',methods=['POST', 'GET'])
  def store():
     if request.method=='POST':
        name=request.form['name']
        mycursor.execute("""INSERT INTO railway (name) VALUES (%s)""",(name))
        mydb.commit()
        return "record inserted."
     else:
        return "s"
  
  if __name__ == "__main__":
      app.run(host='0.0.0.0', port=5000)
  </code></pre>