title: Uploading a CSV file to mysql with Flask, Only first line being uploaded
body: <p>I am creating a piece of code which will take a csv file and upload the content of the file to a mysql database. </p>
  
  <p>I am conducting this process with Flask, Python 2.7 and MySQL-python==1.2.5. </p>
  
  <p>Currently I have a script (shown below) which fulfils this task, however I can only get the csv file to read/ upload the first row of the csv file.
  Any help would be much appreciated.  </p>
  
  <p>CSVFILE: </p>
  
  <pre><code>date_time,first_name,surname,address,email
  2018/03/23 12:09:10,Steve,Jones,UK,SteveJones@hotmail.com
  2018/03/23 12:12:20,Jack,Flipper,UK,JackFlipper@hotmail.com
  2018/03/23 12:14:30,Rebecca,Fletcher,France,RebeccaFletcher@hotmail.com
  2018/03/23 12:15:10,Aby,Jones,Italy,AbyJones@hotmail.com
  </code></pre>
  
  <p>PYTHON:</p>
  
  <pre><code>import os
  import io
  import csv
  from flask import render_template, request, redirect, url_for,flash
  from flask_login import current_user, login_required
  from flask_sqlalchemy import SQLAlchemy
  from flask.ext.uploads import UploadSet, configure_uploads, DATA
  from werkzeug.utils import secure_filename
  from . import upload_csv_blueprint
  from .. import db
  from .. models import details
  
  @upload_csv_blueprint.route('/upload_csv_layout', methods=['POST' , 'GET'])
  @login_required
  def upload_csv_layout():
  
      return render_template('upload_csv.html', title='upload_csv')
  
  @upload_csv_blueprint.route('/upload_csv', methods=['GET','POST'])
  def upload_file():
    if request.method == 'POST':
        csvfile = request.files['file']
  
        reader = csv.DictReader(csvfile)
        data = [row for row in reader]
        for row in data:
            date_time_store = row['date_time']
            first_name_store = row['first_name']
            surname_store = row['surname']
            address_store = row['address']
            email_store = row['email']
  
            query = details(date_time = date_time_store,first_name=first_name_store,surname=surname_store,address=address_store,email=email_store)
            db.session.add(query)
            db.session.commit()
            return('Did it work?')
    else:
        return redirect(url_for('upload_csv.upload_csv_layout'))
  </code></pre>
  
  <p>HTML OF PAGE: </p>
  
  <pre><code>{% import 'bootstrap/utils.html' as utils %}
  {% import 'bootstrap/wtf.html' as wtf %}
  {% extends '/advanced_banner.html' %}
      {% block body %}
        &lt;title&gt; Upload CSV &lt;/title&gt;
              &lt;form method=POST enctype=multipart/form-data action='/upload_csv'&gt;
                  &lt;input type='file' name='file' class='UCSV_FileInput'&gt;&lt;/input&gt;
                      &lt;button type='submit' value='Upload'&gt;Submit&lt;/button&gt;
              &lt;/form&gt;
          &lt;/div&gt;
          &lt;div class='flash_holding_box'&gt;
              &lt;div class='flash'&gt;&lt;b&gt; Action Log &lt;/b&gt; &lt;br&gt;{{utils.flashed_messages()}}&lt;/div&gt;
          &lt;/div&gt;
      {% endblock %}
  </code></pre>
  
  <p>Understand that my imports are a bit wacky, but been trying a few different techniques. </p>