2

Django 1.7 文档中,规定 Django 用户必须具有许多 CREATE 权限才能使用新python manage.py migrate命令。这显然假设 Django 项目需要写入数据库。如果没有怎么办?如果我不想使用怎么办migrate

我正在开始一个项目,我将在其中使用 Oracle 数据库,但不打算给 Django 任何写权限。我惊讶地发现,python manage.py runserver即使项目为空,我也无法运行,而我只有一个settings.py文件。相反,我收到以下错误消息:

django.db.utils.DatabaseError: ORA-01031: insufficient privileges

我该如何解决这个问题?

[编辑] 同样有趣的是,如果我将 Oracle 作为默认数据库并进入 shell,我实际上可以正常进行查询。

[编辑 2]追溯...

[myproject]yourstruly@myserver /projects/django/myproject2 $ python manage.py runserver 0.0.0.0:8001Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x1ce36e0>
Traceback (most recent call last):
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/utils/autoreload.py", line 222, in wrapper
    fn(*args, **kwargs)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
    self.check_migrations()
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 159, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/migrations/executor.py", line 17, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/migrations/loader.py", line 48, in __init__
    self.build_graph()
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/migrations/loader.py", line 179, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
    self.ensure_schema()
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 53, in ensure_schema
    editor.create_model(self.Migration)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/backends/schema.py", line 270, in create_model
    self.execute(sql, params)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/backends/schema.py", line 98, in execute
    cursor.execute(sql, params)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/projects/.virtualenv/myproject/lib/python2.7/site-packages/django/db/backends/oracle/base.py", line 916, in execute
    return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: OprojectsA-01031: insufficient privileges
4

0 回答 0