Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Delete Query | Implement CRUD
Flask Intensive Course: Web Development with Python

bookDelete Query

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.

recipe = 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.

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 4

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Awesome!

Completion rate improved to 3.85

bookDelete Query

Scorri per mostrare il menu

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.

recipe = 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.

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 4
some-alt