Guest User

Untitled

a guest
Dec 13th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. # gcloud login and check the DB
  2. !gcloud auth login
  3. !gcloud config set project [YOUR PROJECT ID]
  4. !gcloud sql instances describe [YOUR CLOUDSQL INSTANCE ID]
  5.  
  6. # download and initialize the psql proxy
  7. !wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
  8. !chmod +x cloud_sql_proxy
  9. # "connectionName" is from the previous block
  10. !nohup ./cloud_sql_proxy -instances="[connectionName]"=tcp:5432 &
  11. !sleep 30s
  12.  
  13. !cat nohup.out
  14.  
  15. conn = psycopg2.connect(
  16. host='127.0.0.1', port='5432', database=[YOUR DB NAME],
  17. user=[USERNAME], password=[PASSWORD])
Add Comment
Please, Sign In to add comment