【问题标题】:django inspectdb ORA-00904 "IDENTITY_COLUMN"django inspectdb ORA-00904 "IDENTITY_COLUMN"
【发布时间】:2019-06-15 02:06:29
【问题描述】:

我目前正在尝试通过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,我认为发生错误是因为我在表中没有主键,但由于我不确定,我不想对现有数据库进行任何更改。

有人解决了这个问题吗?

【问题讨论】:

  • 您可以保存数据库的转储文件,然后尝试链接中的解决方案,如果您认为自己搞砸了任何事情,您可以从转储文件中恢复数据库的状态。

标签: python django database oracle django-models


【解决方案1】:

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

# 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

【讨论】:

    猜你喜欢
    • 2019-01-06
    • 2017-06-20
    • 1970-01-01
    • 2021-06-03
    • 1970-01-01
    • 2019-06-21
    • 1970-01-01
    • 1970-01-01
    • 2021-05-09
    相关资源
    最近更新 更多