Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # gcloud login and check the DB
- !gcloud auth login
- !gcloud config set project [YOUR PROJECT ID]
- !gcloud sql instances describe [YOUR CLOUDSQL INSTANCE ID]
- # download and initialize the psql proxy
- !wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
- !chmod +x cloud_sql_proxy
- # "connectionName" is from the previous block
- !nohup ./cloud_sql_proxy -instances="[connectionName]"=tcp:5432 &
- !sleep 30s
- !cat nohup.out
- conn = psycopg2.connect(
- host='127.0.0.1', port='5432', database=[YOUR DB NAME],
- user=[USERNAME], password=[PASSWORD])
Add Comment
Please, Sign In to add comment