I'm trying to programmatically import some shapefiles to PostGIS, since I need to catch the exit code of the process I decided to use subprocess.Popen. I've managed to import the files using:
cmd = ["ogr2ogr","-f", "PostgreSQL", "PG:dbname=idegeo host=localhost port=5432 user=postgres password=postgres",
"-nlt", "PROMOTE_TO_MULTI","-nln","tablename",
"-unsetFieldWidth","shape.shp"]
process = subprocess.Popen(cmd,stdout=subprocess.PIPE)
output = process.communicate()[0]
Now, the only thing I'm having problems is in passing the argument --config PG_USE_COPY YES to increase performance (as suggested here).
I've tried using [someargs,"--config", "PG_USE_COPY YES"] but Popen refuses to recognize the value passed to --config
["-f","PostgreSQL"]so if i pass the full string"--config PG_USE_COPY YES"I getUnknown option name '--config PG_USE_COPY YES'– plablo09 Sep 12 '14 at 17:16["ogr2ogr","--config" ,"PG_USE_COPY", "YES"..]– plablo09 Sep 14 '14 at 23:18