django oracle inspectdb失败

时间:2011-05-28 00:51:36

标签: django oracle inspectdb

我正在使用django 1.3。我有一个现有的oracle数据库(10g)我想使用inspectdb构建Model。

'db': {
    'ENGINE': 'django.db.backends.oracle',
    'NAME': 'DBNAME',
    'USER': 'me',
    'PASSWORD': 'something',
}

所以当运行inspectdb时我得到:

$ python manage.py inspectdb --database db
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle

所以我添加

$ export ORACLE_HOME=/usr/oracle/
$ TWO_TASK=DBNAME

我尝试使用相同的凭据登录sqlplus,一切看起来都不错。

所以...我再次运行inspectdb,但这次我得到了

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#     * Rearrange models' order
#     * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.

from django.db import models

(即它是空白的)

任何想法?我在使用mysql数据库时没有任何问题。

2 个答案:

答案 0 :(得分:1)

来自官方docs

  

inspectdb适用于PostgreSQL,MySQL和SQLite。外键检测仅适用于PostgreSQL和某些类型的MySQL表。

如果您想提交Django跟踪器,目前没有列出错误。

答案 1 :(得分:0)

我在settings.py的顶部有类似的设置来为我的oracle驱动程序(Oracle 11.2)设置我的环境变量。不确定这是否有助于您的具体情况。

### SETTING  UP THE ENVIRONENT FOR OUR ORACLE RPM 
import os
os.putenv('ORACLE_HOME', '/.../oracle/11.2') 
os.putenv('LD_LIBRARY_PATH', '/.../oracle/11.2/lib')

我对Oracle 11.2上的manage.py inspectdb(Django 1.2.7和Django 1.4)没有任何问题。

相关问题