I am exporting a grass vectior dataset to a Postgis dump file using v.out.ogr (reformatted for clarity)

v.out.ogr -a -n input=my_layer@mapset\
                output=my_sql_file.sql format=PGDUMP

It exports using insert statements by default, but the ogr2ogr docs suggest that using a switch enables COPY format instead (--config PG_USE_COPY YES). COPY is much faster and is also easier to debug when errors occur.

I tried using PG_USE_COPY=YES as both a dsco and lco option, and exporting it (ubuntu 18.04 command line in grass environment).


Is it possible to export using COPY format?

What am I doing wrong?


My problem was caused by creating a layer by merging server datasets, one of which had an ogc_fid field (default primary key for ogr2ogr). This caused loading to fail after several thousand insert statements. I solved it by editing the sql file to rename the primary key and add ogc_fid as an integer field.


1 Answer 1


Thanks to markusN for an answer in a comment.

It looks like it is not possible to export to PGDUMP using COPY rather than INSERT at present.

Direct write access https://grasswiki.osgeo.org/wiki/PostGIS#Direct_write_access appears like a promising approach but I have not tried it.

https://grass.osgeo.org/grass76/manuals/v.out.postgis.html has worked for me, as has manually editing the sql file to convert to copy format (using sed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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