Can SQLAlchemy be used with Google Cloud SQL?

前端 未结 4 1679
一生所求
一生所求 2020-12-01 05:13

I\'ve looked over Google Cloud SQL\'s documentation and various searches, but I can\'t find out whether it is possible to use SQLAlchemy with Google Cloud SQL, and if so, wh

4条回答
  •  离开以前
    2020-12-01 06:11

    For those who prefer PyMySQL over MySQLdb (which is suggested in the accepted answer), the SQLAlchemy connection strings are:

    For Production

    mysql+pymysql://:@/?unix_socket=/cloudsql/

    Please make sure to

    1. Add the SQL instance to your app.yaml:

      beta_settings:
          cloud_sql_instances: 
      
    2. Enable the SQL Admin API as it seems to be necessary:

      https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview

    For Local Development

    mysql+pymysql://:@localhost:3306/

    given that you started the Cloud SQL Proxy with:

    cloud_sql_proxy -instances==tcp:3306

提交回复
热议问题