[Gdal-dev] Newbie queston concerning ogr2ogr for PostgreSQL

Frank Warmerdam warmerdam at pobox.com
Thu Jan 4 11:13:33 EST 2007

Mateusz Loskot wrote:
> Brent Edwards wrote:
>> Why won't this work?:
>> ogr2ogr -f KML kmltest.kml "PG:dbname=postg is username=postgres
>> password=pword" -sql "SELECT * FROM district;"
> PostgreSQL driver in OGR recognizes the same connection string format as
> used by PostgreSQL API. Here is list of supported keys with explanation
> of possible values:
> http://www.postgresql.org/docs/8.1/interactive/libpq.html#LIBPQ-CONNECT

I would add that some versions of OGR do not support the default geometry
verison of some PostGIS versions.  So:

  ogr2ogr -f KML kmltest.kml "PG:..." district

might work better than an explicit SQL statement.  This issue should be
resolved with GDAL/OGR 1.4.0 (at RC1 current).

Also, you don't need to include a semi-colon in your SQL statement.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list