1

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.

APC
  • 144,005
  • 19
  • 170
  • 281
yee379
  • 6,498
  • 10
  • 56
  • 101
  • Someone else asked this on SO a while back. I'm afraid they didn't get an answer either: http://stackoverflow.com/questions/4914775/django-inspectdb-issue-using-oracle-db I hope you have better luck. – APC May 28 '11 at 06:47
  • You can possibly get something by making some changes to the introspect.py file, but I don't know how complete/accurate it would be. See answer given in the previously linked question: http://stackoverflow.com/a/9368226/1212519 – Plecebo Feb 20 '12 at 20:55

2 Answers2

1

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.

thenmal
  • 11
  • 1
0

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.

Patrick
  • 141
  • 1
  • 5