dbdicom.Record.remove#

Record.remove()[source]#

Remove a record from the database.

Example

Create a new study in an empty database, then remove it again:

>>> database = db.database()
>>> study = database.new_study(StudyDescription='Demo Study')
>>> database.print()
---------- DATABASE --------------
Location:  In memory
    Patient New Patient
        Study Demo Study [None]
----------------------------------
>>> study.remove()
>>> database.print()
---------- DATABASE --------------
Location:  In memory
    Patient New Patient
----------------------------------

A record that has been removed from the database can no longer be accessed. Any attempt to do so will raise an error:

>>> print(study.label())
ValueError: This record has been removed from the database and can no longer be accessed.

Note

Removing a record will also remove all of its children, and this will be permanent after saving the record with save().

If a record has been removed accidentally in an interactive session, use restore() to revert back to the last saved state.