title: Using ISO timestamp in Flask-SQLAlchemy
body: <p>I have a date which I obtain from an API. It is in the form of <code>2015-01-01T15:04:23Z</code>.</p>
  
  <p>How can I accept this date into a model using Flask-SQLAlchemy?</p>
  
  <p>So far I have tried, </p>
  
  <pre><code>date = db.Column(db.DateTime)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>date = db.Column(db.DateTime(timezone=True))
  </code></pre>
  
  <p>which gives me the error</p>
  
  <pre><code>StatementError: (exceptions.TypeError) SQLite DateTime type only accepts Python datetime and date objects as input.
  </code></pre>
  
  <p>Also, when I retrieve it using a <code>get</code>, I need it to be in the exact same format.</p>
  
  <p>The <code>dateutil</code> python module parses it well but when I retrieve it from the table, I need to get <code>2015-01-01T15:04:23Z</code>.</p>
  
  <pre><code>&gt;&gt;&gt; from dateutil.parser import parse
  &gt;&gt;&gt; parse('2015-01-01T15:04:23Z')
  datetime.datetime(2015, 1, 1, 15, 4, 23, tzinfo=tzutc())
  </code></pre>