django oracle检查数据库失败

发布于 2024-11-10 15:04:01 字数 1064 浏览 0 评论 0原文

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

'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 数据库上使用它没有任何问题。

i'm using django 1.3. i have an existing oracle database (10g) i would like to build Model's from using inspectdb.

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

so when run inspectdb i get:

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

so i add

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

i try logging on with sqlplus with the same credentials and everything looks good.

so... i run inspectdb again, but this time i get

# 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

(ie it's blank)

any ideas? i had no problems getting this to work on a mysql database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蹲墙角沉默 2024-11-17 15:04:01

来自官方文档

inspectdb 可与 PostgreSQL、MySQL 和 SQLite 配合使用。外键检测仅适用于 PostgreSQL 和某些类型的 MySQL 表。

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

From the official docs.

inspectdb works with PostgreSQL, MySQL and SQLite. Foreign-key detection only works in PostgreSQL and with certain types of MySQL tables.

There is currently not a bug listed for it in the Django tracker if you wanted to submit it.

时光磨忆 2024-11-17 15:04:01

我的 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.pyspectdb(Django 1.2.7 和 Django 1.4)没有任何问题。

I have a similar setup at the top of my settings.py to set my environment variables for my oracle driver (Oracle 11.2). Not sure if this will help in your specific case.

### 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')

I have had no issues with manage.py inspectdb (Django 1.2.7 and Django 1.4) on Oracle 11.2.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文