PostgreSQL
 SQL >> Database >  >> RDS >> PostgreSQL

Elencare database PostgreSQL da Python

Puoi gestire il dump completo con pg_dumpall e psql, eseguiti come superuser.

Per scaricare tutto:

pg_dumpall -h localhost -U postgres -f pg_dumpall.sql

Se ti interessa solo lo schema senza dati, aggiungi --schema-only.

Per ripristinare tutto in un altro cluster:

psql -f pg_dumpall.sql postgres

In Python puoi orchestrare questi comandi con subprocess, oppure interrogare direttamente pg_database.