SqlAlchemy won't accept datetime.datetime.now value in a DateTime column

前端 未结 4 1519
独厮守ぢ
独厮守ぢ 2021-02-18 23:59

I should first mention that I\'m using SqlAlchemy through Flask-SqlAlchemy. I don\'t believe this affects the issue but if it does, please let me know.

Here is the relev

4条回答
  •  臣服心动
    2021-02-19 00:26

    Set the import out the class.

    from datetime import datetime
    
    last_updated = db.Column(db.DateTime, default=datetime.now())
    

    or

    import datetime
    
    last_updated = db.Column(db.DateTime, default=datetime.datetime.now())
    

    I did this

提交回复
热议问题