Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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', }} 
like image 384
Albert Rothman Avatar asked Dec 22 '17 20:12

Albert Rothman


People also ask

Why Postgres is better for Django?

PostgreSQL is the default database choice for many Python developers, including the Django team when testing the Django ORM. PostgreSQL is often viewed as more feature robust and stable when compared to MySQL, SQLServer and Oracle. All of those databases are reasonable choices.

Can I use PostgreSQL with Django?

In this guide, you will install and configure PostgreSQL (often referred to as Postgres) to use with your Django applications. You will install the necessary software, create database credentials for our application, and then start and configure a new Django project to use this backend.

What database is used for Django?

Django officially supports the following databases: PostgreSQL. MariaDB. MySQL.

What is postgresql_psycopg2?

Psycopg is the most popular PostgreSQL database adapter for the Python programming language. Its main features are the complete implementation of the Python DB API 2.0 specification and the thread safety (several threads can share the same connection).


1 Answers

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.

like image 193
Dima Kudosh Avatar answered Oct 14 '22 03:10

Dima Kudosh