Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 754f64f

Browse filesBrowse files
authored
Merge pull request GoogleCloudPlatform#1170 from andrewsg/no-local-mysqldb
Enable PyMySQL as an option for local development.
2 parents d492a47 + 90bfd6a commit 754f64f
Copy full SHA for 754f64f

File tree

Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed

‎appengine/standard/django/mysite/settings.py

Copy file name to clipboardExpand all lines: appengine/standard/django/mysite/settings.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@
9292
# Database
9393
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
9494

95+
# Check to see if MySQLdb is available; if not, have pymysql masquerade as
96+
# MySQLdb. This is a convenience feature for developers who cannot install
97+
# MySQLdb locally; when running in production on Google App Engine Standard
98+
# Environment, MySQLdb will be used.
99+
try:
100+
import MySQLdb # noqa: F401
101+
except ImportError:
102+
import pymysql
103+
pymysql.install_as_MySQLdb()
104+
95105
# [START db_setup]
96106
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'):
97107
# Running on production App Engine, so connect to Google Cloud SQL using
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
MySQL-python==1.2.5
1+
PyMySQL==0.7.11
22
Django==1.11.6

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.