数据库和model对应不上。。。


#1

Apr 4 00:32:45 iZm5eannq0xxj2rpr5raokZ [service_variant=lms][django.request][env:sandbox] ERROR [iZm5eannq0xxj2rpr5raokZ 2467] [base.py:256] - Internal Server Error: /dashboard
Traceback (most recent call last):
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py”, line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py”, line 145, in inner
return func(*args, **kwargs)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py”, line 22, in _wrapped_view
return view_func(request, *args, **kwargs)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py”, line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File “/edx/app/edxapp/edx-platform/common/djangoapps/student/views.py”, line 663, in dashboard
meter = programs_utils.ProgramProgressMeter(user, enrollments=course_enrollments)
File “/edx/app/edxapp/edx-platform/openedx/core/djangoapps/programs/utils.py”, line 191, in init
self.programs = attach_program_detail_url(get_programs(self.user))
File “/edx/app/edxapp/edx-platform/openedx/core/djangoapps/programs/utils.py”, line 52, in get_programs
programs_config = ProgramsApiConfig.current()
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/config_models/models.py”, line 143, in current
current = cls.objects.filter(**key_dict).order_by(’-change_date’)[0]
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py”, line 201, in getitem
return list(qs)[0]
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py”, line 162, in iter
self._fetch_all()
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py”, line 965, in _fetch_all
self._result_cache = list(self.iterator())
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py”, line 238, in iterator
results = compiler.execute_sql()
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py”, line 840, in execute_sql
cursor.execute(sql, params)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/backends/utils.py”, line 64, in execute
return self.cursor.execute(sql, params)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/utils.py”, line 98, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/backends/utils.py”, line 64, in execute
return self.cursor.execute(sql, params)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py”, line 124, in execute
return self.cursor.execute(query, args)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1054, “Unknown column ‘programs_programsapiconfig.api_version_number’ in ‘field list’”)
Apr 4 00:32:46 iZm5eannq0xxj2rpr5raokZ [service_variant=lms][request_cache][env:sandbox] WARNING [iZm5eannq0xxj2rpr5raokZ 2467] [init.py:66] - Could not retrieve the current request. A stub request will be created instead using settings.SITE_NAME. This should be used only in test cases, never in production!

先是说找不到programs_programsapiconfig.api_version_number,表里的确也没这列,但model里是有的,打算重做表,执行:

python.edxapp manger.edxapp lms makemigrations programs

结果又报错

Traceback (most recent call last): File "/edx/bin/manage.edxapp", line 116, in execute_from_command_line([sys.argv[0]] + django_args) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/co re/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/co re/management/__init__.py", line 346, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/co re/management/base.py", line 394, in run_from_argv self.execute(*args, **cmd_options) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/co re/management/base.py", line 445, in execute output = self.handle(*args, **options) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/co re/management/commands/makemigrations.py", line 63, in handle loader = MigrationLoader(None, ignore_no_migrations=True) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /migrations/loader.py", line 47, in __init__ self.build_graph() File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /migrations/loader.py", line 185, in build_graph self.load_disk() File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /migrations/loader.py", line 103, in load_disk migration_module = import_module("%s.%s" % (module_name, migration_name)) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/content/course_over views/migrations/0009_readd_facebook_url.py", line 27, in class Migration(migrations.Migration): File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/content/course_over views/migrations/0009_readd_facebook_url.py", line 39, in Migration fields = table_description() File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/content/course_over views/migrations/0009_readd_facebook_url.py", line 15, in table_description fields = connection.introspection.get_table_description(connection.cursor(), 'course_overviews_courseoverview') File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /backends/base/base.py", line 162, in cursor cursor = self.make_debug_cursor(self._cursor()) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /backends/base/base.py", line 135, in _cursor self.ensure_connection() File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /backends/base/base.py", line 130, in ensure_connection self.connect() File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /utils.py", line 98, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /backends/base/base.py", line 130, in ensure_connection self.connect() File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /backends/base/base.py", line 119, in connect self.connection = self.get_new_connection(conn_params) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db /backends/sqlite3/base.py", line 204, in get_new_connection conn = Database.connect(**conn_params) django.db.utils.OperationalError: unable to open database file

为啥最后去了sqlite??数据库的连接设置是在哪里?


#2

数据库连接是在env.json里面,或者在common.py里面。
你是做了什么操作后出现这个问题?


#3

找到问题了,并不是做了什么,我没用对环境文件
python.edxapp manger.edxapp lms makemigrations programs
中间要加上–settings aws,当然后来我意识到我实际用的是sandbox,可能应该写sandbox,但还没顾上试。
默认的话是dev,我不是dev,dev是用的sqlite,本地开发用?