r-spatial / sf

Simple Features for R
https://r-spatial.github.io/sf/
Other
1.33k stars 293 forks source link

Can't execute query from gdal_utils + ogrinfo #2420

Open latot opened 1 month ago

latot commented 1 month ago

Hi!, I'm trying to use ogrinfo to remove a table from a gpkg:

  sf::gdal_utils(
    util = "ogrinfo",
    file_path,
    options = c(
      "-sql", gsub("{}", name, "DROP TABLE IF EXISTS {}", fixed = TRUE),
      "-dialect", "sqlite"
    )
  )

And I got the next error:

Warning:
In CPL_ogrinfo(if (missing(source)) character(0) else source, options,  :
  GDAL Error 1: In ExecuteSQL(): sqlite3_step(DROP TABLE IF EXISTS tmp):
  attempt to write a readonly database

This command works fine from ogrinfo in the terminal.

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Gentoo Linux

Matrix products: default
BLAS:   /usr/lib64/libblas.so.3.12.0 
LAPACK: /usr/lib64/liblapack.so.3.12.0

locale:
 [1] LC_CTYPE=es_CL.utf8       LC_NUMERIC=C             
 [3] LC_TIME=es_CL.utf8        LC_COLLATE=es_CL.utf8    
 [5] LC_MONETARY=es_CL.utf8    LC_MESSAGES=es_CL.utf8   
 [7] LC_PAPER=es_CL.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=es_CL.utf8 LC_IDENTIFICATION=C      

time zone: Chile/Continental
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.4.1     magrittr_2.0.3     class_7.3-22       tools_4.4.1       
 [5] DBI_1.2.3          units_0.8-5        proxy_0.4-27       Rcpp_1.0.12       
 [9] KernSmooth_2.23-24 grid_4.4.1         e1071_1.7-14       classInt_0.4-10   
[13] sf_1.0-17 

Thx!

edzer commented 2 weeks ago

Pls reinstall from source, and try again.