OperationalError at /api/v01/cron-jobs/process-data-objects/
(2002, "Can't connect to local MySQL server through socket '/cloudsql/cm-platform-01:europe-west1:cm-db-develop' (2)")
Request Method: GET Request URL: http://cm-platform-01.appspot.com/api/v01/cron-jobs/process-data-objects/ Django Version: 1.10.4 Exception Type: OperationalError Exception Value: (2002, "Can't connect to local MySQL server through socket '/cloudsql/cm-platform-01:europe-west1:cm-db-develop' (2)")Exception Location: /env/lib/python3.5/site-packages/MySQLdb/connections.py in __init__, line 204 Python Executable: /env/bin/python3.5 Python Version: 3.5.2 Python Path: ['/home/vmagent/app',
'/env/bin',
'/env/lib/python35.zip',
'/env/lib/python3.5',
'/env/lib/python3.5/plat-linux',
'/env/lib/python3.5/lib-dynload',
'/opt/python3.5/lib/python3.5',
'/opt/python3.5/lib/python3.5/plat-linux',
'/env/lib/python3.5/site-packages']
Server time: Wed, 12 Apr 2017 12:27:56 +0000
Django==1.10.4
Pillow==3.4.2
mysqlclient==1.3.10
django-cors-headers==2.0.2
djangorestframework==3.5.4
djangorestframework-jwt==1.9.0
django-crispy-forms==1.6.1
django-filter==1.0.1
gunicorn==19.6
google-api-python-client==1.5.5
google-cloud-storage==0.22.0
python-magic==0.4.12
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/cm-platform-01:europe-west1:cm-db-develop',
'NAME': 'cm_develop_01',
'USER': 'cm-django-app',
'PASSWORD': '[the-password]'
}
# [START runtime]
runtime: custom
env: flex
entrypoint: gunicorn -b :$PORT common.wsgi
beta_settings:
cloud_sql_instances: cm-platform-01:europe-west1:cm-db-develop
runtime_config:
python_version: 3
# [END runtime]
FROM gcr.io/google_appengine/pythonLABEL python_version=python3.5
RUN virtualenv --no-download /env -p python3.5
RUN apt-get update && apt-get install -y libmagic-dev
# Set virtualenv environment variables. This is equivalent to running
# source /env/bin/activate
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
ADD requirements.txt /app/
RUN pip install -r requirements.txt
ADD . /app/
CMD exec gunicorn -b :$PORT common.wsgi
Hello Tas,
To allow your app to connect to your Cloud SQL instance when the app is deployed, add the user, password, database, and instance connection name variables from Cloud SQL to the related environment variables in the app.yaml file:
env_variables:
# Replace user, password, database, and instance connection name with the values obtained
# when configuring your Cloud SQL instance.
SQLALCHEMY_DATABASE_URI: >-
mysql+pymysql://USER:PASSWORD@/DATABASE?unix_socket=/cloudsql/INSTANCE_CONNECTION_NAME
It may be worthwhile to check in detail this information and the other related steps in the “Using Cloud SQL for MySQL” document. This solution, with relevant detail, is given in the “cloudsql databases with django on 'new' flexible google app engine” question on Stackoverflow.
The “Running Django in the App Engine Flexible Environment” documentation page might prove quite helpful for related details.