首页 > 解决方案 > ogr2ogr 查询以“”作为命令的分隔符,并且在查询中导致空响应

问题描述

使用 ogr2ogr 我将地理数据从 postgis 数据库查询到 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 命令来查询“自然”?

标签: postgresqlpostgisgdalogr2ogr

解决方案


双引号应该被转义:

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

推荐阅读