Copy database with python..
p at ulmcnett.com
Fri Nov 2 15:19:54 CET 2007
> I want to copy my database but python give me error when i use this
> 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
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.
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
> 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
More information about the Python-list