如何通过aws redshift管理django' orm?

时间:2018-04-18 08:58:40

标签: python django amazon-redshift

我是AWS redshift的新开发人员。

据我所知,AWS redshift非常类似于postgresql

redshift和Django之间是否有任何用于管理的库或模块(如自动迁移,自动迁移)?

我确实创建了一个表并使用SQLAlchemy和redshift访问数据,但我不知道如何在python Django中做这件事。

任何建议或想法都没问题!

我用这个命令

得到了这个错误
python manage.py migrate


django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (Column "django_migrations.id" has unsupported type "serial".

1 个答案:

答案 0 :(得分:1)

您可以轻松地将RedShift服务与Django App连接。

尝试将以下代码添加到settings.py文件

DATABASES = {
    'default': {
        'NAME': '[Your Cluster Name]',
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': '[Username ]',
        'PASSWORD': '[Password]',
        'HOST': '[Pathname]',
        'PORT': 5439,
    },
}

,您需要知道Redshift不会强制执行主键。在我看来,使用Redshift作为Django应用程序中的默认数据库并不是一个好主意,因为Redshift是数据仓库的有用数据库而不是应用程序。

首先,我的建议是PostgreSQL。