Passing options to ogr2ogr using python subprocess.Popen

المشرف العام

Administrator
طاقم الإدارة
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



أكثر...
 
أعلى