Friday, 23 February 2018

Execute ogr2ogr from python


I tried to execute ogr2ogr from python with this shell command:



ogr2ogr.exe --config PG_LIST_ALL_TABLES YES -f "PostgreSQL" -append PG:"host=hostnamet user=username password=password dbname=dbname" nasfile.xml

The quick and dirty solution with os.system doesn't work. There is no data in the database after run this script:


import os
loadfile = path\\file.xml

command = "C:\\Program Files\\QGIS Chugiak\\bin\\ogr2ogr.exe --config PG_LIST_ALL_TABLES YES -f \"PostgreSQL\" -append PG:\"host=hostname user=username password=password dbname=dbname\" " + loadfile

os.system(command)


What is the right syntax to execute it with subprocess.call?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...