Error Inspectdb with PostgreSQL/Redshift


I have a django webapp that is currently using postgresql for its backend. I have some data in another database (Redshift) that I would like to create models from. When I run ‘python inspectdb --database redshift’ I get the below response for all the tables I have in Redshift.

from django.db import models

Unable to inspect table ‘my_table’

The error was: list index out of range

I’ve checked my Redshift user permissions and I have access to all the Tables. Has anyone else run into a similar issue? I appreciate any feedback or guidance.


I’m using…
Django 4.1.2
django-redshift-backend 3.0.0
‘default’: {
‘ENGINE’: ‘django.db.backends.postgresql’,
‘NAME’: os.environ.get(‘NAME’),
‘USER’: os.environ.get(‘USER’),
‘PASSWORD’: os.environ.get(‘PASSWORD’),
‘HOST’: os.environ.get(‘HOST’),
‘PORT’: os.environ.get(‘PORT’),
‘redshift’: {
‘ENGINE’: ‘django_redshift_backend’,
‘NAME’: os.environ.get(‘RDATABASE’),
‘USER’: os.environ.get(‘RUSER’),
‘PASSWORD’: os.environ.get(‘RPASSWORD’),
‘HOST’: os.environ.get(‘RHOST’),
‘PORT’: os.environ.get(‘RPORT’),
‘options’: ‘-c search_path=int’

I think the first thing I would try would be to manually create a model for one table, then verify that I can access the database using the Django shell.

That at least would verify that you have the settings correct and your installation is able to access the database.

1 Like

Thanks, @KenWhitesell I was able to query my redshift table via django shell. Turns out I needed to adjust my IAM policy and everything worked.

However, I am getting another error when running: “python inspectdb --database=redshift my_table > my_app/”, django will begin to write the model, but I get the below error…

AttributeError: ‘FieldInfo’ object has no attribute ‘is_autofield’

Is this a datatype confliction between redshift and django?

I’m sorry, I don’t know anything about redshift - hopefully someone else here is able to provide assistance.