1

I'm trying to connect to Amazon Redshift database with my django application. In my settings.py I've got this setting:

DATABASES = {
    "default": {},
    'redshift': {
        'NAME': 'xxxx',
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': 'xxxx',
        'PASSWORD': 'xxxxxx',
        'HOST': 'xxxx.xxxx.eu-west-1.redshift.amazonaws.com',
        'PORT': 5439,
    }
}

When I try to run my application I get this error :

Traceback (most recent call last):
   File "manage.py", line 12, in <module>
     execute_from_command_line(sys.argv)
  File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/core/management/__init__.py", line 346, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/core/management/base.py", line 394, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/core/management/base.py", line 445, in execute
     output = self.handle(*args, **options)
  File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/migrations/executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
  File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/migrations/loader.py", line 47, in __init__
self.build_graph()
  File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/migrations/loader.py", line 188, in build_graph
self.applied_migrations = recorder.applied_migrations()
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
self.ensure_schema()
  File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 53, in ensure_schema
editor.create_model(self.Migration)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 286, in create_model
self.execute(sql, params or None)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 111, in execute
cursor.execute(sql, params)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise
raise value.with_traceback(tb)
   File "/Users/stevengerrits/anaconda/envs/djangoweb/lib/python3.4/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
 django.db.utils.NotSupportedError: Column "django_migrations.id" has unsupported type "serial".

I googled it but seems like django is not a good framework to work with redshift, is that true??

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
user5488652
  • 421
  • 3
  • 8
  • 15
  • Possible duplicate of [Redshift DB backend for Django](http://stackoverflow.com/questions/24795394/redshift-db-backend-for-django). Also see this question: http://stackoverflow.com/questions/32719478/using-django-multiple-databases-with-redshift – dguay Dec 03 '15 at 14:01
  • I did read both of them, but can't find an answer... – user5488652 Dec 03 '15 at 14:17
  • What you mean? The second link is clearly an answer to your question. – dguay Dec 03 '15 at 14:19
  • "don't use Django migrations with redshift. Syncdb might be ok, to initialize your tables, but after that you will need to manage the schema manually" - I don't understand everything.. – user5488652 Dec 03 '15 at 14:50
  • I would not use Redshift (It's a DWH solution) with Django - but what this means: Manage the Redshift DB manually (create tables and columns over its interface/cli) and disable Django migrations: [model.managed=False](https://docs.djangoproject.com/en/2.0/ref/models/options/#managed) or [MIGRATION_MODULES](https://docs.djangoproject.com/en/2.0/ref/settings/#migration-modules) – wiesion Jun 04 '18 at 00:26

0 Answers0