I have a problem with SQLAlchemy
SQLite Date type only accepts Python date objects as input.[SQL: 'UPDATE records SET timestamp=?][parameters: [{'timestamp': (datetime.date(2017, 6, 15),)}]]
This is my Forms.py
class DataForm(FlaskForm):
timestamp = DateField("date", validators=[Required()])
class ModifyDataForm(FlaskForm):
timestamp = DateField("date", validators=[Required()])
This is my Models.py
class Record(db.Model):
timestamp = db.Column(db.Date, default=date.today, index=True)
Views.py
def create():
form = DataForm()
if form.validate_on_submit():
record = Record(timestamp=form.timestamp.data,)
def modify(id):
record = Record.query.get_or_404(id)
form = ModifyDataForm(record)
if form.validate_on_submit():
record.timestamp = form.timestamp.data,
form.timestamp.data = record.timestamp
Template I use bootstrap's wtf.html
when I create a data, input '2017-06-18',that's ok.
But when I update data,the sqlalchemy raise:
>>>SQLite Date type only accepts Python date objects as input.[SQL: 'UPDATE records SET timestamp=?][parameters: [{'timestamp': (datetime.date(2017, 6, 15),)}]]
Where am I wrong? Does datetime.date isn't a Python date object?Why the first time is worked? How can I fix it.
My English is poor, if any confused, ask me again.
Thanks!