Skip to content

Instantly share code, notes, and snippets.

@dblodgett-usgs
Created October 3, 2022 22:14
Show Gist options
  • Save dblodgett-usgs/61425b5cb58bd570a47e7ed054a8d7b5 to your computer and use it in GitHub Desktop.
Save dblodgett-usgs/61425b5cb58bd570a47e7ed054a8d7b5 to your computer and use it in GitHub Desktop.
remove gpkg layer with R using RSQLite
remove_gpkg_table <- function(db, table) {
con <- RSQLite::dbConnect(RSQLite::SQLite(), db)
on.exit(RSQLite::dbDisconnect(con))
o <- RSQLite::dbRemoveTable(con, table)
o <- RSQLite::dbSendQuery(con, sprintf("DELETE FROM gpkg_contents where table_name='%s';", table))
RSQLite::dbClearResult(o)
}
@edzer
Copy link

edzer commented Oct 6, 2022

For completeness: sf::st_delete() does this.

@dblodgett-usgs
Copy link
Author

lol -- I've searched for this a number of times and totally missed that st_delete exists. Thanks @edzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment