Connecting to the instance from our application
To connect with Cloud SQL instances from our Python code, we use the MySQLdb
package, which is a MySQL driver that implements the Python Database API as described in the PEP 249 document. To install the package, we can use pip
; from the command line, we issue the following command:
pip install MySQL-python
We don't specify the -t
option as we did when installing GCS Client Library in Chapter 3, Storing and Processing Users' Data because the MySQLdb
package is included in App Engine Python Runtime Environment on the production servers and we don't need to upload it during deployment. Instead, we list the package in the libraries
section of the app.yaml
file:
libraries: - name: webapp2 version: "2.5.2" ...
Get Python for Google App Engine now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.