Skip to content

Commit a2f4c7f

Browse files
iotmanichenyumic
authored and
chenyumic
committed
Fix for error when missing MySQLdb (GoogleCloudPlatform#1728)
* Fix for error when missing MySQLdb * Update settings.py * Update settings.py * Update settings.py
1 parent e461e9a commit a2f4c7f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

appengine/standard_python37/django/mysite/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
# Database
8080
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
8181

82+
# Install PyMySQL as mysqlclient/MySQLdb to use Django's mysqlclient adapter
83+
# See https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-db-api-drivers for
84+
# more information
85+
import pymysql
86+
pymysql.install_as_MySQLdb()
87+
8288
# [START db_setup]
8389
if os.getenv('GAE_APPLICATION', None):
8490
# Running on production App Engine, so connect to Google Cloud SQL using
@@ -89,6 +95,7 @@
8995
'HOST': '/cloudsql/[YOUR-CONNECTION-NAME]',
9096
'USER': '[YOUR-USERNAME]',
9197
'PASSWORD': '[YOUR-PASSWORD]',
98+
'NAME': '[YOUR-DATABASE]',
9299
}
93100
}
94101
else:

0 commit comments

Comments
 (0)