title: python sqlite ValueError: Couldn't parse datetime string
body: <p>I have a .txt file which I use to fill a sqlite table FoodConsumed_tb </p>
  
  <pre><code>class FoodConsumed_Tb(db.Model):
      __tablename__ = 'foodconsumed_tb'
      id = db.Column(db.Integer, primary_key=True)
      date_created = db.Column(db.DateTime)
      item = db.Column(db.String(200), nullable=False)
      nutritionalvalue_id = db.Column(db.Integer, ForeignKey('nutritionalvalues.id'))
      amount = db.Column(db.Float, nullable=False)
  </code></pre>
  
  <p>by</p>
  
  <pre><code>p.communicate(b"""
  INSERT INTO foodconsumed_tb
           (date_created,
            item,
            amount,
           );
  .separator ","
  .import ate_records.txt foodconsumed_tb
  """)
  </code></pre>
  
  <p>the ate_records.txt looks like</p>
  
  <pre><code>  1,2019-08-24,Broccoli Chinese,17,1.57 
    2,2019-08-24,chia seeds,11,0.20
    3,2019-08-24,flax seeds,25,0.20
    4,2019-08-24,sunflower seeds,26,0.30
    ....
  </code></pre>
  
  <p>This works and the table is filled with all the records. But when I come and try and use this table using  </p>
  
  <pre><code>consumedfoods = FoodConsumed_Tb.query.order_by(FoodConsumed_Tb.date_created).all()
  </code></pre>
  
  <p>I get the error</p>
  
  <pre><code>ValueError: Couldn't parse datetime string: '2019-08-24'
  </code></pre>
  
  <p>For dates that get entered into the table via a form (I'm making a flask app) I use</p>
  
  <pre><code>date_created=datetime.strptime(date, "%Y-%m-%d").date()
  </code></pre>
  
  <p>where 'date' comes from form.request['date'], works fine as I'm formatting the date.</p>
  
  <p>But when I just import the all the records into the table from a .txt file, I don't know how to format the date?</p>
  
  <p>I've been trying this</p>
  
  <pre><code>from flask import Flask, render_template, url_for, request, redirect
  from flask_sqlalchemy import SQLAlchemy
  from datetime import datetime
  
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
  app.config['SECRET_KEY'] = 'secret' 
  db = SQLAlchemy(app)
  
  from app import FoodConsumed_Tb
  
  rows = FoodConsumed_Tb.query.all()
  
  for row in rows:
      consumed_food_entry_to_update = FoodConsumed_Tb.query.get_or_404(row.id)
      consumed_food_entry_to_update.date_created = datetime.strptime(consumed_food_entry_to_update.date_created, "%Y-%m-%d").date()
  
  db.session.commit()
  </code></pre>
  
  <p>but it says</p>
  
  <pre><code>ValueError: Couldn't parse datetime string: '2019-08-24'
  </code></pre>