If you're getting intermittent connection errors, try increasing one or both of If you have trouble with the SSH Tunnel connection, the project provides a This example uses the psycopg2 library, but you can use any Postgres local_bind_port, database = 'your database name', ) # Do stuff inside the context manager block connection. ![]() connect ( user = 'a postgres user', password = 'password for the postgres user', host = '127.0.0.1', port = tunnel. SSHTunnelForwarder ( ( '' ), ssh_username = 'your PythonAnywhere username', ssh_password = 'the password you use to log in to the PythonAnywhere website', remote_bind_address = ( postgres_hostname, postgres_host_port ) ) as tunnel : connection = psycopg2. TUNNEL_TIMEOUT = 5.0 postgres_hostname = "" # You will have your own here postgres_host_port = 1234 # You will have your own port here with sshtunnel. Your Postgres database, you can install the sshtunnel packageĪnd then use code like this: import psycopg2 import sshtunnel sshtunnel. ![]() If you're running Python code on your local machine, and you want it to access There are a number of ways to do this: From Python code ¶
0 Comments
Leave a Reply. |