Question: I want to run [inspectdb](https://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-inspectdb) against an Oracle database. The user account that I use is a read only user that owns 0 tables. It, however, has access to the schema that contains all the tables. How do I specify a schema when using `inspectdb`?

My command, currently, is: `python manage.py inspectdb --database "oradb" > test_model.py`

This only outputs a file with `from django.db import models`.

Answer: 
My two cents in. (django version 1.9.7 + django GIS extension)

Following Andy and Mirek Simek suggestions I further modified:

added *'schemas'* in your db config in **settings.py**

```
    ...
    'oracle1': {
        'ENGINE': 'django.contrib.gis.db.backends.oracle',
        'NAME': 'dbname',
        'USER': 'dbuser',
        'PASSWORD': 'dbpass',
        'HOST': 'dbhostname',
        'PORT': 'dbport',
        'schemas': ['SCHEMANAME1', ....] #<-- this
    }, 
    ...

```

modified **get\_tables\_list** in this way:

```
def get_table_list(self, cursor):
    """
    Returns a list of table and view names in the current database.
    """
    cursor.execute("SELECT TABLE_NAME, 't' FROM USER_TABLES UNION ALL "
                   "SELECT VIEW_NAME, 'v' FROM USER_VIEWS")
    res = [TableInfo(row[0].lower(), row[1]) for row in cursor.fetchall()]

    schemas = self.connection.settings_dict.get('schemas')
    if schemas and len(schemas)>0:
        for s in schemas:
            cursor.execute("SELECT TABLE_NAME, 't' FROM ALL_TABLES WHERE OWNER = '%s'" %s)
            for row in cursor.fetchall():
                tbl_name, typ = '.'.join([s,row[0].lower()]), row[1]
                try:
                    # let us check for permission to query
                    cursor.execute("SELECT * FROM %s WHERE ROWNUM < 1" % tbl_name.upper())
                except DatabaseError, e:
                    pass
                else:
                    res.append(TableInfo(tbl_name, typ))
    return res

```

Cause I'm using gis I had to make a dirty patch (I don't know if it is needed due to database issue) to **django/contrib/gis/db/backends/oracle/introspection.py**

just added this at the end of **get\_geometry\_type**

```
    ...
        dim = len(dim)
        if dim != 2:
            field_params['dim'] = dim
    except:  # <-- this
        pass # <-- this
    finally:
        cursor.close()
    ...

```
Try to specify the search\_path, by adding an option in your DATABASES variable at settings.py, like that:

```
'OPTIONS': {
       'options': '-c search_path=myschema'
}

```

The full DATABASES variable should be:

```
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mydatabase',
        'USER': 'postgres',
        'PASSWORD': 'mypassword',
        'HOST': 'localhost',
        'PORT': '5432',
        'OPTIONS': {
            'options': '-c search_path=myschema'
        }
    }
}

```

After that `python migrate inspectdb` should work on your schema