Я пытаюсь отладить RALPH (сервер, использующий инфраструктуру DJANGO для взаимодействия с MySQL). Я уже видел эту проблему вокруг, но не ясный (для меня) окончательный ответ. Пожалуйста, учтите, что я полный питон, новичок. Сервер фактически не работает и возвращает Server Error (500)
, в то время как журнал сообщает об исключении django (см. Ниже).
Здесь _do_query () из cursors.py
...
def _do_query(self, q):
db = self._get_db()
self._last_executed = q
db.query(q)
self._do_get_result()
return self.rowcount
...
и запрос () из connections.py
...
def query(self, query):
# Since _mysql releases GIL while querying, we need immutable buffer.
if isinstance(query, bytearray):
query = bytes(query)
if self.waiter is not None:
self.send_query(query)
self.waiter(self.fileno())
self.read_query_result()
else:
_mysql.connection.query(self, query)
...
Вот трассировка всех журналов:
Traceback (most recent call last):
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1054, "Unknown column 'assets_asset.start_usage' in 'field list'")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.6/contextlib.py", line 52, in inner
return func(*args, **kwds)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/contrib/admin/options.py", line 618, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/contrib/admin/sites.py", line 233, in inner
return view(request, *args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/reversion/revisions.py", line 297, in do_revision_context
return func(*args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/admin/mixins.py", line 141, in changelist_view
response = super().changelist_view(request, *args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/admin/mixins.py", line 313, in changelist_view
request, extra_context
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/admin/mixins.py", line 223, in changelist_view
return super().changelist_view(request, extra_context)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/reversion/admin.py", line 419, in changelist_view
return super(VersionAdmin, self).changelist_view(request, context)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/utils/decorators.py", line 34, in _wrapper
return bound_func(*args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/utils/decorators.py", line 30, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1657, in changelist_view
selection_note=_('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/query.py", line 144, in __len__
self._fetch_all()
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/lib/polymorphic/models.py", line 113, in iterator
for obj in model_query:
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/query.py", line 162, in __iter__
self._fetch_all()
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/query.py", line 238, in iterator
results = compiler.execute_sql()
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
cursor.execute(sql, params)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1054, "Unknown column 'assets_asset.start_usage' in 'field list'")