title: How to create table and insert data using MySQL and Flask
body: <p>I am trying to insert data into a MySQL table. I'm able to connect to the database but when trying to insert data it is giving internal server error.</p>
  
  <pre><code>from flask import Flask
  from flaskext.mysql import MySQL
  
  mysql = MySQL()
  app = Flask(__name__)
  app.config['MYSQL_DATABASE_USER'] = 'root'
  app.config['MYSQL_DATABASE_DB'] = 'test'
  app.config['MYSQL_DATABASE_HOST'] = 'localhost'
  mysql.init_app(app)
  
  @app.route("/")
  def create_table():
      cursor = mysql.get_db().cursor()
      query = "CREATE TABLE potlala (id INT NOT NULL PRIMARY KEY, name  VARCHAR(40), email VARCHAR(40))"
      query = "INSERT INTO pot13 (id, name, email) VALUES ('2222', 'Maria',  'mariaz@activestate.com')"
      cursor.execute(query)
      return "123"
  
  if __name__ == "__main__":
      app.run()
  </code></pre>