Skip to content

Commit d757e84

Browse files
authored
Merge pull request #1 from iotmani/iotmani-patch-1
Fix for error when missing MySQLdb
2 parents b561761 + 123c4d5 commit d757e84

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

appengine/standard_python37/django/mysite/settings.py

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

82+
# Check to see if MySQLdb is available; if not, have pymysql masquerade as
83+
# MySQLdb. This is a convenience feature for developers who cannot install
84+
# MySQLdb locally; when running in production on Google App Engine Standard
85+
# Environment, MySQLdb will be used.
86+
try:
87+
import MySQLdb # noqa: F401
88+
except ImportError:
89+
import pymysql
90+
pymysql.install_as_MySQLdb()
91+
8292
# [START db_setup]
8393
if os.getenv('GAE_APPLICATION', None):
8494
# Running on production App Engine, so connect to Google Cloud SQL using

0 commit comments

Comments
 (0)