最近我在对Google App Engine上的应用进行更新时,正在更新数据库:
SETTINGS_MODE='prod' ./manage.py syncdb
上次运行时这个代码可以正常工作,但现在出现了以下错误:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/c/clients/green_rentals/code/green-rental/south/management/commands/syncdb.py", line 92, in handle_noargs
syncdb.Command().execute(**options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", line 159, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/c/downloads/python/google_appengine/google/storage/speckle/python/django/backend/base.py", line 263, in _cursor
if not self._valid_connection():
File "/c/downloads/python/google_appengine/google/storage/speckle/python/django/backend/base.py", line 258, in _valid_connection
return super(DatabaseWrapper, self)._valid_connection()
AttributeError: 'super' object has no attribute '_valid_connection'
我尝试将Google App Engine SDK更新到最新版本(1.8.8),并尝试通过oauth重新验证身份(已成功)。但仍然收到相同的消息。有任何线索吗?
提前感谢您的帮助!
编辑:
看起来我用于数据库连接的设置最近已更改。我过去使用的是:
DATABASES = {
'default': {
'ENGINE': 'google.appengine.ext.django.backends.rdbms',
'INSTANCE': 'project-id:instance-id',
'NAME': 'name',
}
}
但是现在的建议是:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/your-project-id:your-instance-name',
'NAME': 'database-name',
'USER': 'mysql-user',
}
}
更新后,我现在遇到了一个新的错误:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/c/clients/green_rentals/code/green-rental/south/management/commands/syncdb.py", line 89, in handle_noargs
db.connection_init()
File "/c/clients/green_rentals/code/green-rental/south/db/mysql.py", line 180, in connection_init
cursor = self._get_connection().cursor()
File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", line 159, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", line 129, in _cursor
self.ensure_connection()
File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", line 124, in ensure_connection
self.connect()
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", line 124, in ensure_connection
self.connect()
File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", line 112, in connect
self.connection = self.get_new_connection(conn_params)
File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 435, in get_new_connection
conn = Database.connect(**conn_params)
File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/cloudsql/your-project-id:your-instance-name' (2)")
(其中your-project-id:your-instance-name已经相应更改)