Second gen GAE Python 3.7 > Cloud SQL - MySQL

161 views
Skip to first unread message

Frank Heinen

unread,
Sep 11, 2018, 11:56:45 AM9/11/18
to Google App Engine
Does someone know how to connect to Cloud SQL - MySQL DB from a new Second generation App Engine with Python 3.7?

The documentation of Google seems incomplete here at the moment. 

Olu

unread,
Sep 11, 2018, 11:22:24 PM9/11/18
to Google App Engine
There are different ways to connect to the CloudSQL instance depending on the location from where you are connecting. If you are connecting from an App Engine instance which is located in a project which is different from the project which the CloudSQL instance resides, you must use a service account to allow connection between the App Engine application and the Cloud SQL as described in the link.

However, when connecting from your App Engine Application within the same project, you simply have to configure your app.yaml with the user, password, database, and instance connection name variables from Cloud SQL, See the documentation

External applications have to connect to the Cloud SQL instances directly through the public IP address and the IP addresses of the connecting application have to be white listed in the Cloud SQL instance on the Authorization Tab of the Instance page.


Eric G

unread,
Sep 12, 2018, 11:00:08 AM9/12/18
to Google App Engine
Thanks for this. The second link is to the flex environment documentation. Are you saying that App Engine standard 2nd gen uses the same method of connecting to CloudSQL instances as flex, i.e. via the unix socket  /cloudsql/INSTANCE_CONNECTION_NAME ?  If so, it would be helpful to have those instructions/example on the first link (to standard 2nd gen) as well.

Personally, I would like to see an example that doesn't depend on SQLAlchemy + Flask, otherwise people may think they have to use those. I guess it's not hard to figure out but just some acknowledgement that you can set your own environment variables and manually use them to connect with pymysql or whatever adapter.

rah...@google.com

unread,
Sep 16, 2018, 10:11:38 AM9/16/18
to Google App Engine
You should be able to use any library which works with mysql or postgres to connect using the unix socket /cloudsql/....

Steren Giannini

unread,
Sep 17, 2018, 11:47:22 AM9/17/18
to google-a...@googlegroups.com
Hi,
Yes GAE second generation expose a /cloudsql socket to access Cloud SQL. Sorry about the lack of docs, we are in the process of (better) documenting it.

Steren
Product Manager

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/469db80a-f980-4468-b56e-138eb5b6e731%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric G

unread,
Sep 18, 2018, 1:03:24 PM9/18/18
to Google App Engine
No problem, thanks for your work.
Reply all
Reply to author
Forward
0 new messages