summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mysql/gaerdbms.py
diff options
context:
space:
mode:
authorBrett Slatkin <brett@haxor.com>2013-06-08 00:10:26 -0700
committerBrett Slatkin <brett@haxor.com>2013-06-08 00:10:26 -0700
commit2dee20448ca5ac2cd8d877b0d67ad49bcb2859e1 (patch)
treed3ca9fa3a2d59c6c39a765fbe6e3b5cfc49f0643 /lib/sqlalchemy/dialects/mysql/gaerdbms.py
parentd5363fca5400f6c4969c2756fcfcdae6b9703091 (diff)
downloadsqlalchemy-2dee20448ca5ac2cd8d877b0d67ad49bcb2859e1.tar.gz
Makes gaerdbms for App Engine use local MySQL server when running under dev_appserver2.
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql/gaerdbms.py')
-rw-r--r--lib/sqlalchemy/dialects/mysql/gaerdbms.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/gaerdbms.py b/lib/sqlalchemy/dialects/mysql/gaerdbms.py
index ad0ce7638..0c08b1483 100644
--- a/lib/sqlalchemy/dialects/mysql/gaerdbms.py
+++ b/lib/sqlalchemy/dialects/mysql/gaerdbms.py
@@ -26,11 +26,17 @@ default.
"""
+import os
+
from .mysqldb import MySQLDialect_mysqldb
from ...pool import NullPool
import re
+def _IsDevEnvironment():
+ return os.environ.get('SERVER_SOFTWARE', '').startswith('Development/')
+
+
class MySQLDialect_gaerdbms(MySQLDialect_mysqldb):
@classmethod
@@ -43,7 +49,10 @@ class MySQLDialect_gaerdbms(MySQLDialect_mysqldb):
# see also http://stackoverflow.com/q/14224679/34549
from google.appengine.api import apiproxy_stub_map
- if apiproxy_stub_map.apiproxy.GetStub('rdbms'):
+ if _IsDevEnvironment():
+ from google.appengine.api import rdbms_mysqldb
+ return rdbms_mysqldb
+ elif apiproxy_stub_map.apiproxy.GetStub('rdbms'):
from google.storage.speckle.python.api import rdbms_apiproxy
return rdbms_apiproxy
else:
@@ -57,11 +66,11 @@ class MySQLDialect_gaerdbms(MySQLDialect_mysqldb):
def create_connect_args(self, url):
opts = url.translate_connect_args()
- # 'dsn' and 'instance' are because we are skipping
- # the traditional google.api.rdbms wrapper
-
- opts['dsn'] = ''
- opts['instance'] = url.query['instance']
+ if not _IsDevEnvironment():
+ # 'dsn' and 'instance' are because we are skipping
+ # the traditional google.api.rdbms wrapper
+ opts['dsn'] = ''
+ opts['instance'] = url.query['instance']
return [], opts
def _extract_error_code(self, exception):