ogr2ogr 查询以“”作为命令的分隔符并且在查询结果中为空响应

ogr2ogr query with " " as separator for the command and within the query results in empty response

使用 ogr2ogr,我将 postgis 数据库中的地理数据查询到 Geopackage 中。主要属性是 "natural",用“”包裹。查询也由“”包裹。这会导致空响应/geopackage

命令是: 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" <> ''"

如何在没有“ ”的情况下为 ogr2ogr 包装 sql-命令以查询 "natural"?

应该转义双引号:

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\" <> ''"