Trying to use ogr2ogr to import a shapefile in PostgreSQL. Here is my command:

ogr2ogr -append -f "PostgreSQL" PG:"host=localhost user=postgres dbname=routing " C:\Users\rizagha\Documents\ex_RWg2cV8o94r6J4c1zMUeEcSAZSvkA_osm_line.shp -nln edges -lco geometry_name=geom -t_srs EPSG:4326

ERROR 1: Unable to find driver `PostgreSQL'.

but I have used ogr2ogr to import fileGDB's into PostgreSQL and it has always worked... not sure what's wrong with my command.

I took out append and it still doesn't work.

1 Answer 1


what ogr2ogr are you using. Not all GDAL is compiled with PostgreSQL driver. For example the ogr2ogr that gets packaged with PostGIS bundle on windows is not compiled with PostgreSQL driver becuase it's included just to verify data used by ogrfdw. ogrfdw doesn't need PostgreSQL driver in GDAL for most use cases because it's already living in PostgreSQL side.

To verify you have the PostgreSQL driver, run:

ogr2ogr --formats
  • this is really really strange, it doesn't have PostgreSQL driver but I have installed the driver for it from gisinternals for windows and have imported FilGDB's to posgres with it..
    – ziggy
    Commented Jul 21, 2017 at 18:41
  • i guess il have to reinstall the driver...somehow it just magically went away
    – ziggy
    Commented Jul 21, 2017 at 18:41
  • 1
    It could be maybe the postgis one you have in your environment path so that's the one being picked up when you run that. I would explicitly set the full path to the ogr2ogr from gisinternals, or as part of your batch script, overwrite the PATH variable. You could also just delete the one in the PostgreSQL folder to ensure it doesn't get picked up. There isn't much need for it if you are using the gisinternals one. The only reason I include it is because ogrfdw didn't spit out formats, and that's the only way I could verify which drivers are included.
    – Regina Obe
    Commented Jul 21, 2017 at 18:44
  • I deleted the gdal files, reinstalled the gisinternals one and it worked!
    – ziggy
    Commented Jul 28, 2017 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.