-1

I need to access the remote database server(linux) and also take its dump to my local(mac).

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'test-name',
    'USER': 'test-user',
    'PASSWORD': 'pwd',
    'HOST': 'test.amazonaws.com',
    }
}
Nick
  • 7,103
  • 2
  • 21
  • 43
Hayz
  • 53
  • 12

1 Answers1

0

In local bash, you can connect and dump the remote database with pg_dump command, see Copying PostgreSQL database to another server

Using Python is similar, except that you need to use psycopg2 module to connect and send commands to database server. You may find this post useful Postgresql Database Backup Using Python

Alternatively, if you need to execute the script in the database server, a better idea would be dump it remotely, then fetch it to local machine.

Community
  • 1
  • 1
Neo X
  • 947
  • 7
  • 9