Abandoned wrote:

> Hi.
> I want to copy my database but python give me error when i use this
> command.
> cursor.execute("pg_dump mydata > old.dump")
> What is the problem ? And how can i copy the database with python ?


You are just going to have to give us more to go on. Please post the 
entire traceback of the error that you see (copy/paste it from your 
terminal).

You can't issue system commands using the cursor's execute() method and 
expect that to work. execute() is for executing SQL, DML, or DDL, not 
for doing shell stuff.

Try:

import os
os.system("pg_dump mydata > /tmp/old.dump")

but I'm not versed in postgressql, so this probably won't work exactly 
as written. You'd need to run that code from the server hosting the 
postgresql database.


> Note: The database's size is 200 GB

Well, then you may want to make sure you have enough room on the target 
volume before trying to dump the file! Note that the dump file could 
conceivably be much larger (or much smaller) than the database itself.


-- 
pkm ~ http://paulmcnett.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to