您好,登录后才能下订单哦!
insert into table
a. create an object based on the Module
b. db.session.add(object)
select * from table
a. Classname(based on the Module).query.all()
select * from table where
a. Classname.query.filter_by(condition=value).all()
select * from table where xxx limit 1
a. Classname.query.filter_by(condition=value).first()
select count(*) from table where xxx
a. Classname.query.filter_by(condition=value).count()
select * from table where primarykey=xx
a. Classname.query.get(xx/id)
7. update column
a. fetch object, eg. flight = Flight.query.get(x)
b. flight.column = newValue
8. delete from table
a. fetch object, eg. flight = Flight.query.get(x)
b. db.session.delete(object)
Advanced sql:
a. Classname.query.order_by(Classname.column).all()
b. Classname.query.order_by(Classname.column.desc()).all()
c. Classname.query.filter(Classname.column != value).all()
d. Classname.query.filter(Classname.column.like(%abc%)).all()
e. Classname.query.filter(Classname.column.in_(aPythonValueList)).all()
f. Classname.query.filter(and_(condition1, condition2, ...)).all()
g. Classname.query.filter(or_(condition1, condition2, ...)).all()
h. db.session.query(Classname1, Classname2).filter(Classname1.column == Classname2.column).all()
Notice:
insert, update, delete:
should add a statement: db.session.commit()
一对多,多对多对象关系SQL语法:
https://www.jianshu.com/p/8c038f0134f8
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。