Google Cloud SQL Template

Remix this template to connect a Google Cloud SQL Server in Python. See Connect to Google Cloud SQL for information on how to setup your service account.

gcloud-sql-proxy (Bash)
This service can be used in other runtimes using gcloud-sql-proxy as host name.
You can make this service available to other runtimes by adding it to "Service Runtimes" in their runtime settings.
Script to start this runtime:
import psycopg2 as pg
conn = pg.connect(host='gcloud-sql-proxy', database='postgres', user='postgres', password='postgres')
0.5s
Python
cursor = conn.cursor()
cursor.execute('select 1')
rows = cursor.fetchall()
cursor.close()
print(rows[:1])
0.6s
Python
Runtimes (2)