Unable to connect to Cloud SQL using PyMySQL

I am trying to connect to Cloud SQL from a Python application (using PyMySQL 0.7.9) running on top of the Google App Engine.

My connection string looks like this (credentials are fake, of course):

pymysql.connect(unix_socket='/cloudsql/gae_project_name:cloudsql_instance_name', 
                user='user', password='', db='database_name')

The error message I get is:

OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 97] Address family not supported by protocol)")

This is similar to PyMySQL, not recognizing that I am trying to connect via a Unix socket and instead set the default value for the host argument (which I assume localhost)

I can connect to MySQLdb with the same connection string.

+4
source share
1 answer

Why not use MySQLdb instead?

Flask PyMySQL, . MySQLDb aha..!

+1

Source: https://habr.com/ru/post/1662063/


All Articles