[gdal-dev] Ogr2ogr, SQLite and overwriting existing database

Even Rouault even.rouault at spatialys.com
Wed May 9 09:42:31 PDT 2018


Hi,

> What is the expected behavior if user asks ogr2ogr to create a SQLite
> database that already exists? The driver page
> http://www.gdal.org/drv_sqlite.html tells that "The SQLite driver supports
> creating new SQLite database files, or adding tables to existing ones. Note
> that a new database file cannot be created over an existing file."

Outdated statement from 1.X era (just removed it). Now that the SQLite driver is a GDAL 
driver, it follows the general mechanism of deleting the existing file.

> 
> But if I lock the existing database by creating a connection into it I get
> these messages: ERROR 1: A file system object called 'foo.gpkg' already
> exists.
> ERROR 1: gpkg driver failed to create foo.gpkg
> 
> Does "ERROR 1: A file system object called 'foo.gpkg' already exists." mean
> that the purpose to prevent overwriting but the check does not work? I have
> been using quit overwriting as a feature but is it actually a bug?

This is a particularity of the GPKG driver. The file should have normally deleted but due t thhe 
lock QuietDelete() failed. And the GPKG driver has a specific code to prevent overwriting of 
an exiting file in its Create() method. In fact it errors out if APPEND_SUBDATASET=YES is not 
specified, and if it is specified it happens a new raster dataset to the existing file

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180509/00f0b0fa/attachment.html>


More information about the gdal-dev mailing list