How to delete records?

SQLRecords can be deleted with record.delete(), which will permanently remove them from your database.

When it comes to records of Artifact and Collection, they are “moved into trash” when you first call record.delete().

  • Trashed records are invisible in the UI and excluded from the query results.

  • If a record is already in the trash or permanent=True is passed, calling record.delete() triggers permanent delete.

# !pip install lamindb
!lamin init --storage test-delete
 initialized lamindb: testuser1/test-delete
import lamindb as ln
import pandas as pd
 connected lamindb: testuser1/test-delete
artifact = ln.Artifact.from_dataframe(
    pd.DataFrame({"a": [1, 2], "b": [3, 4]}), description="mydf"
)
artifact.save()
! no run & transform got linked, call `ln.track()` & re-run
 writing the in-memory object into cache
Artifact(uid='9jdvvPsYxfj6Ab2u0000', version=None, is_latest=True, key=None, description='mydf', suffix='.parquet', kind='dataset', otype='DataFrame', size=2114, hash='2VmqQBSmMtsP5DmA2rhT2w', n_files=None, n_observations=2, branch_id=1, space_id=1, storage_id=1, run_id=None, schema_id=None, created_by_id=1, created_at=2025-11-14 00:11:44 UTC, is_locked=False)
ln.Artifact.to_dataframe()
uid key description suffix kind otype size hash n_files n_observations version is_latest is_locked created_at branch_id space_id storage_id run_id schema_id created_by_id
id
1 9jdvvPsYxfj6Ab2u0000 None mydf .parquet dataset DataFrame 2114 2VmqQBSmMtsP5DmA2rhT2w None 2 None True False 2025-11-14 00:11:44.752000+00:00 1 1 1 None None 1

Trash an artifact

artifact.delete()
! moved record to trash (branch_id = -1): Artifact(uid='9jdvvPsYxfj6Ab2u0000', version=None, is_latest=True, key=None, description='mydf', suffix='.parquet', kind='dataset', otype='DataFrame', size=2114, hash='2VmqQBSmMtsP5DmA2rhT2w', n_files=None, n_observations=2, branch_id=-1, space_id=1, storage_id=1, run_id=None, schema_id=None, created_by_id=1, created_at=2025-11-14 00:11:44 UTC, is_locked=False)

No longer visible:

ln.Artifact.to_dataframe()
uid id key description suffix kind otype size hash n_files n_observations version is_latest is_locked created_at branch_id space_id storage_id run_id schema_id created_by_id

But the artifact still exists in the database and in storage, you can find it by passing None to the visibility filter:

ln.Artifact.filter(visibility=None).to_dataframe()
uid key description suffix kind otype size hash n_files n_observations version is_latest is_locked created_at branch_id space_id storage_id run_id schema_id created_by_id
id
1 9jdvvPsYxfj6Ab2u0000 None mydf .parquet dataset DataFrame 2114 2VmqQBSmMtsP5DmA2rhT2w None 2 None True False 2025-11-14 00:11:44.752000+00:00 -1 1 1 None None 1

You can restore an artifact from trash:

artifact.restore()
ln.Artifact.to_dataframe()
uid key description suffix kind otype size hash n_files n_observations version is_latest is_locked created_at branch_id space_id storage_id run_id schema_id created_by_id
id
1 9jdvvPsYxfj6Ab2u0000 None mydf .parquet dataset DataFrame 2114 2VmqQBSmMtsP5DmA2rhT2w None 2 None True False 2025-11-14 00:11:44.752000+00:00 1 1 1 None None 1
ln.Storage.to_dataframe()
uid root description type region instance_uid is_locked created_at branch_id space_id created_by_id run_id
id
1 Dep9x2gAKEl5 /home/runner/work/lamindb/lamindb/docs/faq/tes... None local None 4Kf3utIIfnlJ False 2025-11-14 00:11:41.947000+00:00 1 1 1 None

Permanent delete

Calling artifact.delete on a trashed artifact triggers a permanent delete dialog. You can pass permanent=True to auto-confirm the deletion.

artifact.delete(permanent=True)

Now its gone in the database:

ln.Artifact.filter(visibility=None).to_dataframe()
uid id key description suffix kind otype size hash n_files n_observations version is_latest is_locked created_at branch_id space_id storage_id run_id schema_id created_by_id
!lamin delete --force test-delete
 deleting instance testuser1/test-delete