postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?

问题描述 投票:3回答:1

我曾经使用python一段时间,但从来没有django。我正在接手一个不同的员工在离开公司之前做的项目。我想知道选项postgresql和postgresql_psycopg2作为django的数据库驱动程序之间是否存在差异。

在一些文章和关于如何设置django项目的文档中我只看到了postgresql,在others中我看到了postgresql_psycopg2。我在提到psycopg2的文档(herehere)中找不到任何内容,所以这只是编写选项的旧方法吗?

一个只是另一个的别名还是它们实际上是不同的引擎?我也找不到任何其他SO问题。

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',# here I also saw postgres_psycopg2
    'NAME': 'premqcsite',
    'USER': 'django_user',
    'PASSWORD': 'Encepta_123',
    'HOST': 'localhost',
    'PORT': '5432',
}}
python django python-3.x postgresql
1个回答
6
投票

一样的。 django.db.backends.postgresql_psycopg2在django <1.8中使用,并在django 1.9中更名为django.db.backends.postgresql。来自docs:

在Django 1.9中更改:

在旧版本中,django.db.backends.postgresql后端名为django.db.backends.postgresql_psycopg2。为了向后兼容,旧名称仍适用于较新版本。

© www.soinside.com 2019 - 2024. All rights reserved.