Skip to main content

Deleting data

Basic Delete

You can delete rows by calling the delete function like this:

from abstra.tables import delete

deleted = delete("users", {"id": 123})
deleted # [{"name": "foo", "email": "bar"}]

Which is equivalent to

DELETE FROM users
WHERE id = 123
RETURNING *

Delete by ID

If you only need to set the id in the where filter, you can use delete_by_id instead:

from abstra.tables import delete_by_id

deleted = delete_by_id(
"users",
id=123
)
deleted # [{"name": "foo", "email": "bar"}]

Which is equivalent to

DELETE FROM users
WHERE id = 123
RETURNING *