I have users
table in my MySql database. This table has id
, name
and age
fields.
How can I delete some record by id
?
Now I use the following code:
user = User.query.get(id)
db.session.delete(user)
db.session.commit()
But I don't want to make any query before delete operation. Is there any way to do this? I know, I can use db.engine.execute("delete from users where id=...")
, but I would like to use delete()
method.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…