Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pypgstac function for deleting collections/items #144

Open
hrodmn opened this issue Oct 20, 2022 · 7 comments
Open

pypgstac function for deleting collections/items #144

hrodmn opened this issue Oct 20, 2022 · 7 comments

Comments

@hrodmn
Copy link
Collaborator

hrodmn commented Oct 20, 2022

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?

@slesaad
Copy link

slesaad commented Nov 21, 2022

these methods would be really useful

@ryanjdillon
Copy link

I would also like these methods.

@bitner
Copy link
Collaborator

bitner commented Jan 3, 2023

@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

@alexgleith
Copy link

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.

@alexgleith
Copy link

Did we get anywhere with this?

I'd also like to know if we can 'truncate' a collection, even by connecting to postgres.

@alexgleith
Copy link

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';

@davidcalhoun
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants