国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

python - How does SQLAlchemy insert data into the corresponding id?
巴扎黑
巴扎黑 2017-05-24 11:34:51
0
2
843

I want to insert or modify a piece of data in the row corresponding to the id, but I don’t know how to do it

巴扎黑
巴扎黑

reply all(2)
習(xí)慣沉默

To add, delete, check and modify, just go to the document.

model = Model.query.get(id)
or model = Model.query.filter_by(id=id).first()

model.name = 'new name'

db.session.add(model)
db.session.commit()
黃舟

If you insert data by specifying the ID, it is unlikely if it is the primary key, but it can be updated. And if it is not the primary key, then 2 operations can be achieved. The code is similar to the following:

Add as:

model = Model(name='new names')
db.session.add(model)
db.session.commit()

Then update to:

model.name = 'new name'
db.session.add(model)
db.session.commit()
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template