2nd generation Google cloud SQL - App Engine

前端 未结 2 1439
一个人的身影
一个人的身影 2021-01-13 04:30

Delighted to see that you have rolled out 2nd generation cloud SQL in Beta. However, I see that it is not available yet to GAE projects. Can you estimate when this link will

相关标签:
2条回答
  • 2021-01-13 04:42

    As of April 27, 2016 Second Generation connectivity to App Engine is supported.


    OLD content:

    The Cloud SQL team is actively working on adding App Engine support for Second Generation instances. Unfortunately I can't speak about specific dates, but we hope to make it available as soon as possible.

    0 讨论(0)
  • 2021-01-13 04:44

    You can now connect to second generation Google Cloud SQL instances from App Engine apps. The connection string is slightly different from first generation instances (docs).

    1. Open your SQL instance in the cloud console.
    2. Under properties copy the "Instance connection name". Note that this is different to the 'name' of your instance and will probably follow the format project:region:instance.
    3. It is normal for the UI to say "None" for authorized applications - you will still be able to connect from GAE. Note: the SQL instance and GAE app must be part of the same project.
      Update: Don't have to be in the same project, you need to grant access if they are not in the same project. Ref: https://cloud.google.com/sql/docs/dev-access#gaev1-csqlv2-access

    Example PHP connection code:

    $con = "mysql:unix_socket=/cloudsql/CONNECTION_STRING_FROM_CONSOLE;dbname=some_db";
    $this->db = new pdo($con, "root", "");
    $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    0 讨论(0)
提交回复
热议问题