Delete Query
Video Player is loading.
Loaded: 0%
Current Time 0:00
/
Duration -:-
- , opens subtitles settings dialogsubtitles settings
- subtitles off
- , selectedEnglish Captions
1x
- 2x
- 1.5x
- , selected1x
- 0.5x
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
Let's discuss the process of DELETING data from the database. Return to our Python Console and give the delete query a try. Deleting is a simple process – you just need to invoke the database object and use the delete()
method instead of add()
. Then, pass the object you want to delete.
If you've closed your terminal or Python Console, don't worry. You can simply import db, Recipe, app to get back on track.
python91234567recipe = Recipe.query.get(4)db.session.delete(recipe)# we haven't commit this change yet.db.session.commit()# now it should work now and its gone.Recipe.query.all()
It's pretty much for deleting just to know id
.
Tout était clair ?
Merci pour vos commentaires !
Section 3. Chapitre 4
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion