Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a python script that i am trying to run in order to dump a postgres table and I noticed there is a pgsql2shp command in bash to perform this easily but I would like to incoperate the same command in a python script and also use parameter substitution. I thought the following would work but it hasn't yielded any result. What is the equivalent of the this command in python

(pgsql2shp -f %s.shp -h localhost -p 5432 testdb "%s_%s")%(table,table,test)
share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can use Pythons Subprocess module to execute shell commands.

command = 'pgsql2shp -f %s.shp -h localhost -p 5432 testdb \"%s_%s\" ' % (table,table,test) sp.call(command.split())

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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