- session.commit() vs session.flush()
default vs server_default
orm默认值 vs 数据库默认值
onupdate vs server_onupdate
orm自动更新 vs 数据库自动更新
db.engine.execute vs db.session.execute
engine vs session vs connection
db.DateTime vs db.TIMESTAMP
表字段默认值default必须传方法名,不带()
1
2addtime = db.Column('f_addtime', db.TIMESTAMP, default=datetime.now)
lasttime = db.Column('f_lasttime', db.TIMESTAMP, onupdate=datetime.now)
参考资料:
SQLAlchemy docs
SQLAlchemy: engine, connection and session difference
flask-sqlalchemy中 backref lazy的参数实例解释和选择
SQLalchemy relationship之lazy属性 学习笔记
ORM SQLAlchemy - 建立一个关系 relationship