2

我们使用来自 appengine 的 google cloud sql,并且从我们的后端实例中经常收到以下错误。

 File "/base/data/home/apps/s~app-prod/140-backend.363823736662468595/users/reports/__init__.py", line 360, in get_document_types
  cursor.execute('SELECT DISTINCT document_type FROM receipt WHERE ho_key=%s AND document_type IS NOT NULL', (str(ho.key())))
File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 499, in execute
  self._DoExec(request)
File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 375, in _DoExec
  response = self._conn.MakeRequest('Exec', request)
File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 873, in MakeRequest
  response = self._MakeRetriableRequest(stub_method, request)
File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 897, in _MakeRetriableRequest
  response = self.MakeRequestImpl(stub_method, request)
File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms_apiproxy.py", line 68, in MakeRequestImpl
  raise OperationalError('could not connect: ' + str(e))

OperationalError:无法连接:ApplicationError:1002

其他人有这方面的经验吗?

谢谢

4

1 回答 1

1

此错误和堆栈跟踪表明您正在使用旧且已弃用的 google.appengine.api.rdbms 接口。

您应该将其替换为 MySQLdb 模块,该模块被记录为在 Python 中从 App Engine 连接到 Cloud SQL的最佳方式。因为这两个接口都符合PEP 249,所以它应该是一个替代品。如上面关于 GAE 的链接所述,您将希望使用MySQLdb.connect(unix_socket="/cloudsql/project:instance", ...).

于 2015-05-21T23:03:12.793 回答