Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
135 views
in Technique[技术] by (71.8m points)

python - What is the difference between postgres and postgresql_psycopg2 as a database engine for 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.

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?

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',
}}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

Changed in Django 1.9:

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...