googleappengin上的Django数据库引擎

2024-09-27 02:15:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在应用程序引擎上更改数据库引擎时遇到一些问题。在

现在我用的是“谷歌.appengine.ext.django.backends.rdbms“它工作得很好,但速度很慢。在

使用的区别是:

"google.appengine.ext.django.backends.rdbms" or "django.db.backends.mysql"

我在我的设置.py公司名称:

DATABASES = {
    'default': {
        'ENGINE': 'google.appengine.ext.django.backends.rdbms',
        'INSTANCE': 'xenon-notch-461:madplanuge',
        'NAME': 'madplanuge',
    }
}

当我尝试将数据库引擎更改为:

^{pr2}$

我在appengine上遇到服务器错误,appengine的日志显示:

回溯(最近一次呼叫):

  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 267, in Handle
    result = handler(dict(self._environ), self._StartResponse)
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/core/handlers/wsgi.py", line 236, in __call__
    self.load_middleware()
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/core/handlers/base.py", line 49, in load_middleware
    mod = import_module(mw_module)
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/contrib/auth/middleware.py", line 3, in <module>
    from django.contrib.auth.backends import RemoteUserBackend
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/contrib/auth/backends.py", line 3, in <module>
    from django.contrib.auth.models import Permission
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/contrib/auth/models.py", line 8, in <module>
    from django.db import models
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/db/utils.py", line 93, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/db/utils.py", line 27, in load_backend
    return import_module('.base', backend_name)
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/base/data/home/apps/s~xenon-notch-461/2.382413358316680585/libs/django/db/backends/mysql/base.py", line 17, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: this is MySQLdb version (1, 2, 5, 'final', 1), but _mysql is version (1, 2, 4, 'beta', 4)

Tags: appsdjangoinpyimporthomedbdata
1条回答
网友
1楼 · 发布于 2024-09-27 02:15:57

何时使用这两个模块取决于您的环境。您可以在App Enginedocumentation中找到有关如何为工作环境使用备用数据库的更多详细信息。在

基本上,django.db.后端.mysql模块允许在生产环境中运行的Django应用程序与Google云SQL生产实例进行通信。在

另一方面,谷歌.appengine.ext.django后台在开发人员工作站上运行并访问生产云SQL实例时使用后端。在

摘自上述文件。在

  • Use the standard django.db.backends.mysql when running in production and accessing a production Google Cloud SQL instance.
  • Use the standard django.db.backends.mysql when running on a developer workstation and accessing a local MySQL instance. In this case, the application uses the system MySQLdb driver.
  • Use the custom backend google.appengine.ext.django.backends.rdbms when running on a developer workstation and accessing a production Cloud SQL instance.

是的,这个错误似乎与MySQLdb模块的错误版本有关。在

相关问题 更多 >

    热门问题