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)

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)
| improve this answer | |

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.