pgstac
pgstac copied to clipboard
pypgstac function for deleting collections/items
Have you considered adding pypgstac functions for deleting collections and items? I see some SQL functions that seem to do this: delete_collection delete_item
What do you think about adding delete_collections
and delete_items
methods for the Loader
class?
these methods would be really useful
I would also like these methods.
@hrodmn I'm not sure that those are quite appropriate for the Loader class as the Loader is designed to take a file to ingest it. This is definitely something that I would consider exposing otherwise though. What were you thinking for the API? pypgstac delete collection mycollection
This would be great to have.
I'm struggling to do it via PG Admin... I've resorted to truncating the table and re-indexing, which won't work for large collections.
Did we get anywhere with this?
I'd also like to know if we can 'truncate' a collection, even by connecting to postgres.
Oh, nevermind, this is easy when connected to postgres. Just need to update search path, so the local functions are able to be found.
SET search_path = pgstac, public;
DELETE from items where collection = 'collection_name';
Confirming that @alexgleith 's tip works. If you forget to run the SET
command first you may see an error similar to
NOTICE: Updating partition stats 2024-05-29 15:53:23.220797+00
ERROR: relation "partition_sys_meta" does not exist