postgres和postgresql_psycopg2作为django的数据库引擎有什么区别? [英] What is the difference between postgres and postgresql_psycopg2 as a database engine for django?

查看:712
本文介绍了postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用python已有一段时间了,但从未使用过django。我要接管另一个员工在离开我们公司之前所做的项目。我想知道选项postgresql和postgresql_psycopg2作为django的数据库驱动程序是否有区别。

I have worked with python for a while, but never django. I am taking over a project that a different employee made before leaving our company. I am wondering if there is a difference between the option postgresql and postgresql_psycopg2 as a database driver for django.

在某些文章和有关如何设置django项目的文档中我只在其他我已经看到了postgresql_psycopg2。我在文档中找不到任何内容(此处此处),所以这仅仅是编写该代码的旧方法

In some articles and the docs about how to set up a django project I have seen just postgresql and in others I have seen the postgresql_psycopg2. I couldn't find anything in the docs (here or here) that mentioned psycopg2, so is this just the old way of writing the option?

一个是另一个的别名还是它们实际上是不同的enine?我也找不到其他有关此的问题。

Is one just an alias for the other or are they actually different enignes? I also couldn't find any other SO questions on this.

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',
}}


推荐答案

是相同的。 django< 1.8中使用的 django.db.backends.postgresql_psycopg2 ,并在django 1.9中将​​其重命名为 django.db.backends.postgresql
来自文档:

It's the same. django.db.backends.postgresql_psycopg2 used in django <1.8 and it was renamed in django 1.9 to django.db.backends.postgresql. From docs:


在Django 1.9中已更改:

Changed in Django 1.9:

The在旧版本中,django.db.backends.postgresql后端被命名为
django.db.backends.postgresql_psycopg2。为了使
向后兼容,旧名称在新版本中仍然有效。

The django.db.backends.postgresql backend is named django.db.backends.postgresql_psycopg2 in older releases. For backwards compatibility, the old name still works in newer versions.

这篇关于postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆