We’ll know that SQLite is very powerful, embedded relational database management system and it offers a really amazing set of tools to manage approximately all sorts of data. But when it comes Multi-user applications (where multiple users want to use the same databases), It fails. So It is recommended to choose a fully featured relational database management system rather than SQLite.
我们将知道SQLite是非常强大的嵌入式关系数据库管理系统,它提供了一套非常了不起的工具来管理几乎所有类型的数据。 但是,当涉及到多用户应用程序(多个用户希望使用相同的数据库)时,它就会失败。 因此,建议选择功能全面的关系数据库管理系统,而不要选择SQLite。
Some examples of Fully featured RDBMS are MySQL, PostgreSQL, Oracle databases.
功能齐全的RDBMS的一些示例是MySQL,PostgreSQL,Oracle数据库。
Django is very flexible in terms of changing databases.
Django在更改数据库方面非常灵活。
So in this article, we’ll see how we can change the database from SQLite to PostgreSQL.
因此,在本文中,我们将看到如何将数据库从SQLite更改为PostgreSQL。
先决条件 (Prerequisites)
Instead of creating everything from scratch, we’re taking the example of our previous article, in which we’re using SQLite database.
而不是从头开始创建所有内容,我们以上一篇文章为例,其中我们使用SQLite数据库。
If you haven’t read our previous article yet, then here it is https://www.thecrazyprogrammer.com/2019/01/django-models.html
如果您尚未阅读我们的上一篇文章,那么这里是https://www.thecrazyprogrammer.com/2019/01/django-models.html
Let’s start.
开始吧。
步骤1:安装PostgreSQL (Step 1: Install PostgreSQL)
To Install PostgreSQL for Django in Ubuntu:
要在Ubuntu中为Django安装PostgreSQL:
Open terminal and type these two commands.
打开终端并键入这两个命令。
sudo apt-get update
sudo apt-get更新
sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql- contrib
须藤apt-get install python-pip python-dev libpq-dev postgresql postgresql- contrib
To Install PostgreSQL for Django in Windows:
要在Windows中为Django安装PostgreSQL:
Download the installer from its official site: