默认情况下只读Oracle数据库

时间:2014-09-29 01:26:09

标签: python django oracle django-1.7

Django 1.7 documentation中,声明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

0 个答案:

没有答案