1

With ogr2ogr I query geodata from a postgis database into a Geopackage. The main attribute is "natural" which as to wrappend with " ". The query is wrapped by " ", too. This leads into a empty response / geopackage

The command is: ogr2ogr -f "GPKG" natural_EPSG4326.gpkg -nln natural_EPSG4326_point PG:"host=localhost dbname=osmdatabase user=postgres password=*********" -sql "select * from import.osm_point where "natural" <> ''"

How can I wrap the sql-command for ogr2ogr without " " to query "natural"?

Michael
  • 219
  • 2
  • 10
  • Here `natural` is not wrapped in double quotes: https://gis.stackexchange.com/a/98406/104659 – 1737973 Aug 29 '19 at 17:02
  • I'm not talking about QGIS. Please have look at my previous post: https://stackoverflow.com/questions/57679704/regular-query-results-in-syntax-error-with-specific-attribute?noredirect=1#comment101806315_57679704 – Michael Aug 29 '19 at 17:17

1 Answers1

2

The double quote should be escaped:

ogr2ogr -f "GPKG" natural_EPSG4326.gpkg -nln natural_EPSG4326_point PG:"host=localhost dbname=osmdatabase user=postgres password=*********" -sql "select * from import.osm_point where \"natural\" <> ''"
JGH
  • 15,928
  • 4
  • 31
  • 48