Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Postgres value should I use in Django's DATABASE_ENGINE?

It's my first time using PostgreSQL 8.4.2 with Django(I have always used MySQL or sqlite3 in the past). Which value should I use for DATABASE_ENGINE in settings.py, postgresql_psycopg2 or postgresql? How do they differ from each other?

like image 871
Thierry Lam Avatar asked Jan 20 '10 05:01

Thierry Lam


People also ask

Is PostgreSQL good for Django?

If you are building an application with maps or you are storing geographical data, you need to use PostgreSQL, as GeoDjango is only fully compatible with PostgreSQL. PostgreSQL has the richest set of features that are supported by Django.

How do I link my Postgres database to Django?

Setting up PostgreSQL in Django To get Python working with Postgres, you will need to install the “psycopg2” module. Now, go to the below link and download and set up PostgreSQL. create a database name gfg in your Postgres server. Now its time to switch from SQLite to PostgreSQL.

Which database is best for Python Django?

The three most widely used Database Management Systems for Django are SQLite, MySQL, and PostgreSQL. The Django community and official Django documentation state PostgreSQL as the preferred database for Django Web Apps.


1 Answers

Update for Django 1.9

The django.db.backends.postgresql_psycopg2 backend has been renamed to django.db.backends.postgresql in Django 1.9. (The psycopg2 name can still be used for backwards compatibility.)

Essentially, for Django ≥1.9, use django.db.backends.postgresql.

See note in Django's documentation for the ENGINE setting.

History (Django ≤ 1.8)

postgresql_psycopg2 and postgresql both use psycopg, versions 2 and 1 respectively. They are both implemented as C extensions using the libpq API to PostgreSQL.

postgresql_psycopg2 is currently recommended -- the original author has deprecated version 1 and is only making new releases of version 2.

When Django was originally released, psycopg2 was still in beta and was not recommended, but this has long since changed.

like image 103
Michael Greene Avatar answered Sep 18 '22 15:09

Michael Greene