These are some steps I took to deploy the Google Cloud Platform Bookshelf APP using Cloud SQL with Python.  Please review all instructions and proper steps on the link above, there are costs involved to running this exercise.  The steps below were performed after configuring the environment.  A project was created, APIs enabled and the Python Google Cloud SDK was installed.  The example below uses the Cloud SQL Proxy , a Cloud SQL (MySQL) database.


I opened three terminals

➜ bin gcloud auth application-default login
Your browser has been opened to visit:

Credentials saved to file: [/…..pplication_default_credentials.json]

These credentials will be used by any library that requests
Application Default Credentials.

➜ bin gcloud config list
region = us-…
zone = us-…1-a
account =
disable_usage_reporting = False
project = bring-the-code-1342

Your active configuration is: [default]

➜ getting-started-python git:(master)

#Go to binary directory not set in PATH
➜ GoogleCloud ./cloud_sql_proxy -instances=”thatmysqldb”=tcp:3306
#2017/09/02 19:47:22 Listening on for thatmysqldb
#2017/09/02 19:47:22 Ready for new connections

./cloud_sql_proxy -instances=”bring-the-code-1342:us-eastern1:thatmysqldb”=tcp:3306

➜ getting-started-python git:(master) mysql –host –user root –password
#Enter password:
#Welcome to the MySQL monitor. Commands end with ; or \g.
#Your MySQL connection id is 31267
#Server version: 5.7.14-google-log (Google)

#Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

#Oracle is a registered trademark of Oracle Corporation and/or its
#affiliates. Other names may be trademarks of their respective

#Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

#mysql> mysql> CREATE DATABASE bookshelf;
#Query OK, 1 row affected (0.02 sec)

#mysql> CREATE USER ‘bookshelf’ identified by ‘TestPassword’;
#Query OK, 0 rows affected (0.04 sec)

#mysql> GRANT ALL ON *.* TO ‘bookshelf’;
#Query OK, 0 rows affected (0.02 sec)

vi 2-structured-data/
# There are three different ways to store the data in the application.
# You can choose ‘datastore’, ‘cloudsql’, or ‘mongodb’. Be sure to
# configure the respective settings for the one you choose below.
# You do not have to configure the other data backends. If unsure, choose
# ‘datastore’ as it does not require any additional configuration.
DATA_BACKEND = ‘cloudsql’

# Google Cloud Project ID. This can be found on the ‘Overview’ page at
PROJECT_ID = ‘bring-the-code-1342’

# CloudSQL & SQLAlchemy configuration
# Replace the following values the respective values of your Cloud SQL
# instance.
CLOUDSQL_USER = ‘bookshelf’
# Set this value to the Cloud SQL connection name, e.g.
# “project:region:cloudsql-instance”.
# You must also update the value in app.yaml.
CLOUDSQL_CONNECTION_NAME = ‘bring-the-code-1342:us-eastern1:thatmysqldb’

# The CloudSQL proxy is used locally to connect to the cloudsql instance.
# To start the proxy, use:
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
# Port 3306 is the standard MySQL port. If you need to use a different port,
# change the 3306 to a different port number.

vi 2-structured-data/app.yaml
#virtualenv -p python3 env
#source env/bin/activate
#pip install -r requirements.txt

➜ 2-structured-data git:(master) ✗ virtualenv -p python3 env
Already using interpreter /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Using base prefix ‘/Library/Frameworks/Python.framework/Versions/3.6’
New python executable in /Users/thatguy.Dude/Desktop/…/GoogleCloud/python/getting-started-python/2-structured-data/env/bin/python3
Also creating executable in /Users/thatguy.Dude/Desktop/…/GoogleCloud/python/getting-started-python/2-structured-data/env/bin/python
Installing setuptools, pip, wheel…done.

➜ 2-structured-data git:(master) ✗ source env/bin/activate
(env) ➜ 2-structured-data git:(master) ✗

(env) ➜ 2-structured-data git:(master) ✗ pip install -r requirements.txt
zsh: /Users/thatguy.Dude/Desktop/GoogleDrive/Google Drive/Do…….

(env) ➜ 2-structured-data git:(master) ✗ python bookshelf/


➜ GoogleCloud 2017/09/02 20:20:38 Listening on for bring-the-code-1342:us-eastern1:thatmysqldb
2017/09/02 20:20:38 Ready for new connections
2017/09/02 23:10:13 New connection for “bring-the-code-1342:us-eastern1:thatmysqldb”
2017/09/02 23:10:14 Client closed local connection on
INFO:werkzeug: – – [02/Sep/2017 23:12:48] “GET / HTTP/1.1” 302 –
INFO:werkzeug: – – [02/Sep/2017 23:12:48] “GET /books/ HTTP/1.1” 200 –
INFO:werkzeug: – – [02/Sep/2017 23:12:50] “GET /favicon.ico HTTP/1.1” 404 –
INFO:werkzeug: – – [02/Sep/2017 23:12:55] “GET /books/add HTTP/1.1” 200 –
INFO:werkzeug: – – [02/Sep/2017 23:15:54] “POST /books/add HTTP/1.1” 302 –
INFO:werkzeug: – – [02/Sep/2017 23:15:54] “GET /books/1 HTTP/1.1” 200 –
INFO:werkzeug: – – [02/Sep/2017 23:16:03] “GET /books/1/edit HTTP/1.1” 200 –
INFO:werkzeug: – – [02/Sep/2017 23:16:06] “POST /books/1/edit HTTP/1.1” 302 –
INFO:werkzeug: – – [02/Sep/2017 23:16:06] “GET /books/1 HTTP/1.1” 200 –
INFO:werkzeug: – – [02/Sep/2017 23:16:07] “GET /books HTTP/1.1” 301 –
INFO:werkzeug: – – [02/Sep/2017 23:16:07] “GET /books/ HTTP/1.1” 200 –

➜ 2-structured-data git:(master) ✗ python3 bookshelf/
All tables created

(env) ➜ 2-structured-data git:(master) ✗ python3
INFO:werkzeug: * Running on (Press CTRL+C to quit)
INFO:werkzeug: * Restarting with fsevents reloader
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 203-770-172


Open in your browser:

Screen Shot 2017-09-02 at 23.57.14

(env) ➜ 2-structured-data git:(master) ✗ “CTRL + C”

➜ 2-structured-data git:(master) ✗ gcloud app deploy
Services to deploy:

descriptor: [/Users/thatguy.Dude/Desktop/…/GoogleCloud/python/getting-started-python/2-structured-data/app.yaml]
source: [/Users/thatguy.Dude/Desktop/…/GoogleCloud/python/getting-started-python/2-structured-data]
target project: [bring-the-code-1342]
target service: [default]
target version: [20170902t231847]
target url: []


Do you want to continue (Y/n)? Y

Enabling service on project bring-the-code-1342…
Waiting for async operation operations/projectSettings.dc…819 to complete…
Operation finished successfully. The following command can describe the Operation details:
gcloud service-management operations describe operations/projectSettings.dc…819
Beginning deployment of service [default]…
Building and pushing image for service [default]
Some files were skipped. Pass `–verbosity=info` to see which ones.
You may also view the gcloud log file, found at
Started cloud build [ce…a3].
To see logs in the Cloud Console:…a3?project=bring-the-code-1342
———————————————————————————— REMOTE BUILD OUTPUT ————————————————————————————
starting build “ce…a3”


Updating service [default]…

Deployed service [default] to []

You can stream logs from the command line by running:
$ gcloud app logs tail -s default

To view your application in the web browser run:
$ gcloud app browse

Goes to

Screen Shot 2017-09-02 at 23.57.14