Django inspectdb ORA-00904“ IDENTITY_COLUMN”

时间:2019-01-21 16:29:44

标签: python django database oracle django-models

我目前正试图通过python manage.py inspectdb从现有Oracle 11数据库中获取Django(2.1.5版)模型,但是仍然会发生此错误:

Unable to inspect table table_name
The error was: ORA-00904: "IDENTITY_COLUMN": invalid identifier

我尝试使用不同的Django。例。在2.0中,没有发生错误,但是没有为模型创建文本。这个主题上有关SO的另一个问题没有帮助。

基于此link,我认为会发生错误,因为我在表中没有主键,但是由于不确定,因此我不想对现存数据库进行任何更改。

有人解决了这个问题吗?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并解决了这个问题:

# database configuration settings.py
#    'oracle': {
#        'ENGINE': 'django.db.backends.oracle',
#        'NAME': 'host:port/service',
#        'USER': 'database_user',
#        'PASSWORD': 'database_password',
#    }

    pip uninstall django
    pip install Django==1.11.22

    cd <django application>

    python manage.py inspectdb --database oracle <table name> > oraclemodel.py

    pip uninstall django
    pip install Django==2.2.4
相关问题