I try to populate SQLAlchemy model from dictionary. The code part is like that.
data = dict(request.form)
c=customer(**data)
db.session.add(c)
db.session.commit()
All is fine when form does not have date field. However when add date time field to form, it is not possible to fill model. I get this error message.
SQLite DateTime type only accepts Python datetime and date objects as input. [SQL: 'INSERT INTO customer (first_name, last_name, register_date) VALUES (?, ?, ?)'] [parameters: [{'first_name': ['jhon'], 'register_date': ['2010-01-01'], 'last_name': ['snow']}]]
class customer(db.Model):
first_name = db.Column(db.String(200))
last_name= db.Column(db.String(200))
register_date=db.Column(db.DateTime)
How can I fix it?