[gdal-dev] "dialect SQLITE" isn't working as expected in ogr2ogr

Nelson A. de Oliveira naoliv at gmail.com
Wed Oct 26 03:47:28 PDT 2016


Hi!

I can't get a proper output when using "-dialect SQLITE" with ogr2ogr

For example, this properly works:

=====
ogr2ogr -update -append -f "ESRI Shapefile" -sql "SELECT NM_TIPO_LO,
NM_TITULO_, NM_NOME_LO FROM \"35032080500_face\"" -t_srs EPSG:4326
merged.shp 35032080500_face.shp
=====

I can see 4 files, as expected:
merged.dbf, merged.prj, merged.shp and merged.shx


Adding "-dialect SQLITE" (remove the merged* files before running):

=====
ogr2ogr -update -append -f "ESRI Shapefile" -dialect SQLITE -sql "SELECT
NM_TIPO_LO, NM_TITULO_, NM_NOME_LO FROM \"35032080500_face\"" -t_srs
EPSG:4326 merged.shp 35032080500_face.shp
=====

This is only a simpfilied example, as I would like to use some SQLITE
functions that aren't available in OGR SQL, for example.

The problem is: ogr2ogr doesn't give any warning or error message, but
I can see only two files being created: merged.dbf and merged.prj

There isn't any shapefile there.

ogr2ogr's manpage says:
=====
       -dialect dialect:
           SQL dialect. In some cases can be used to use (unoptimized) OGR SQL
           instead of the native SQL of an RDBMS by passing OGRSQL. Starting
           with GDAL 1.10, the 'SQLITE' dialect can also be used with any
           datasource.
=====

http://www.gdal.org/ogr_sql_sqlite.html also says:
=====
Since GDAL/OGR 1.10, the SQLite "dialect" can be used as an alternate
SQL dialect to the OGR SQL dialect. This assumes that GDAL/OGR is built
with support for SQLite (>= 3.6), and preferably with Spatialite support
too to benefit from spatial functions.

The SQLite dialect may be used with any OGR datasource, like the OGR SQL
dialect. It is available through the GDALDataset::ExecuteSQL() method by
specifying the pszDialect to "SQLITE". For the ogrinfo or ogr2ogr
utility, you must specify the "-dialect SQLITE" option.

This is mainly aimed to execute SELECT statements (…)
=====

>From what I understand, I can use "-dialect SQLITE" with any datasource
(including shapefiles, I expect)

Is ogr2ogr somehow not doing what it should do, is the documentation
incomplete (ie, we can use the dialect only with some specific cases) or
there is something else wrong, please?

ogr2ogr is version 2.1.1

Thank you!

Best regards,
Nelson


More information about the gdal-dev mailing list