我在google app引擎上传应用程序后出现以下错误。 但在我的本地机器上一切正常
OperationalError at /users/
(2004, "Can't create TCP/IP socket (-1)")
Request Method: GET
Request URL: http://arctic-anvil-728.appspot.com/users/
Django Version: 1.4.13
Exception Type: OperationalError
Exception Value:
(2004, "Can't create TCP/IP socket (-1)")
Exception Location: /base/data/home/runtimes/python27/python27_lib/versions/third_party/MySQLdb-1.2.4b4/MySQLdb/connections.py in __init__, line 190
Python Executable: /base/data/home/runtimes/python27/python27_dist/python
Python Version: 2.7.5
Python Path:
['/base/data/home/apps/s~arctic-anvil-728/1.379355097665075133',
'/base/data/home/runtimes/python27/python27_dist/lib/python27.zip',
'/base/data/home/runtimes/python27/python27_dist/lib/python2.7',
'/base/data/home/runtimes/python27/python27_dist/lib/python2.7/plat-linux2',
'/base/data/home/runtimes/python27/python27_dist/lib/python2.7/lib-tk',
'/base/data/home/runtimes/python27/python27_dist/lib/python2.7/lib-old',
'/base/data/home/runtimes/python27/python27_dist/lib/python2.7/lib-dynload',
'/base/data/home/runtimes/python27/python27_dist/lib/python2.7/site-packages',
'/base/data/home/runtimes/python27/python27_lib/versions/1',
'/base/data/home/runtimes/python27/python27_lib/versions/third_party/MySQLdb-1.2.4b4',
'/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.4',
'/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0',
'/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3',
'/base/data/home/runtimes/python27/python27_lib/versions/third_party/webob-1.1.1',
'/base/data/home/runtimes/python27/python27_lib/versions/third_party/yaml-3.10']
Server time: Mon, 13 Oct 2014 13:45:19 +0000
请帮我解决这个问题。
先谢谢
答案 0 :(得分:2)
请查看documentation。从App Engine连接时应该使用unix_socket。
答案 1 :(得分:0)
感谢Tony的回答,是的我已阅读文档但没有运气:( 我正在使用谷歌应用引擎的Django休息框架 请查看我的" settings.py"文件:
"""
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*****************************************'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
#'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'my-rest.urls'
WSGI_APPLICATION = 'my-rest.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'INSTANCE': 'appid:sql_instance_id',
'NAME': '********',
'USER': '********',
'HOST': '***.**.**.**',
'PASSWORD': '*********',
}
}
#DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 'app_engine',
# 'USER': 'root',
# 'HOST': 'localhost',
# 'PASSWORD': ''
# }
#}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
]
}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
如果有人想要我的示例代码,那么我可以提供它。 请告诉我这段代码有什么问题。