Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Introduction to PostgreSQL


Database Engines

Django comes with a SQLite database which is great for testing and debugging at the beginning of a project.

However, it is not very suitable for production.

Django also support these database engines:

  • PostgreSQL
  • MariaDB
  • MySQL
  • Oracle

We will take a closer look at the PostgreSQL database engine.


PostgreSQL

PostgreSQL database is an open source relational database, which should cover most demands you have when creating a database for a Django project.

It has a good reputation, it is reliable, and it perform well under most circumstances.

We will add a PostgreSQL database to our Django project.

To be able to use PostgreSQL in Django we have to install a package called psycopg2.


Install psycopg2

Type this command in the command line to install the package. Make sure you are still inn the virtual environment:

pip install psycopg2-binary

The result should be something like this:

Collecting psycopg2-binary
  Downloading psycopg2_binary-2.9.5-cp39-cp39-win_amd64.whl (1.2 MB)
    |████████████████████████████████| 1.2 MB 3.3 MB/s
Installing collected packages: psycopg2-binary
Successfully installed psycopg2-binary-2.9.5
WARNING: You are using pip version 20.2.3; however, version 22.3.1 is available. You should consider upgrading via the 'c:\users\Your Name\myworld\scripts\python.exe -m pip install --upgrade pip' command.

The psycopg2 package is a driver that is necessary for PostgreSQL to work in Python.

We also need a server where we can host the database.

In this tutorial we have chosen the Amazon Web Services (AWS) platform, you will learn more about that in the next chapter.


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.