-
In your local_settings.py file:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'django_%s' % (PROJECT_NAME,), 'USER': xxxx, 'PASSWORD': xxxx, 'HOST': 'localhost', 'PORT': '1234', } }
-
SSH to development server.
To connect to the production server, from the command line, run:
$ ssh -N -L 1234:localhost:5432 remote.com
- 1234 = local port
- 5432 = remote port
Important: Don't close shell window.
Note: After entering the above command, you won't get any feedback until you exit.
-
You might need to
$ touch
your wsgi file or restart Apache (Django development server restarts automatically).
Last active
July 26, 2023 15:22
-
-
Save mhulse/1954422 to your computer and use it in GitHub Desktop.
SSH Tunneling: Map port from remote machine to your local machine so you can work from the remote DB (example using Django DB settings)...
What happens if you break the database in the development server? Will it break the live database too?
Good question. Well, you are connected to the live database, so if you do something that would break it, then it will break. :D
Oh man! But it still a very good way for testing when you don't need the change the db.
Yah! It's a quick way to get live data to work with. If you get this to work with WP, you might fork this file and leave a comment here with a link to your version. :)
For future reference, here's the discussion that spawned this gist via wp-hackers listserv.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This above code shows you how to make a tunnel to a production server in order to make use of it's database contents.