Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python api for postgresql pg_dump*, restore commands

Is there a python library that contains the functionality of the pg_dump, pg_dumpall and restore commands? I want to have the ability to handle exceptions where the standard commands do not allow for that level of control.

Is there anything out here that can help me?

like image 410
CLJ Avatar asked Dec 22 '11 14:12

CLJ


1 Answers

You could try psycopg2. It's a python api to postgres, and you can use the copy_from and copy_to methods on the cursor to do it with StringIO objects and do it all in memory, or just with the disk.

This is only good for data though, i believe.

like image 97
notbad.jpeg Avatar answered Nov 05 '22 10:11

notbad.jpeg