Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which database engine to choose for Django app? [closed]

I'm new to Django and have only been using sqlite3 as a database engine in Django. Now one of the applications I'm working on is getting pretty big, both in terms of models' complexity and requests/second.

How do database engines supported by Django compare in terms of performance? Any pitfalls in using any of them? And the last but not least, how easy is it to switch to another engine once you've used one for a while?

like image 444
Ivan Vashchenko Avatar asked Mar 02 '12 20:03

Ivan Vashchenko


People also ask

Which DB is best for 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.

Which is better SQLite or PostgreSQL?

SQLite doesn't perform well when it comes to user management. It also lacks the ability to handle simultaneous access by multiple users. PostgreSQL performs very well in managing users. It has well-defined permission levels for users that determine what operations they can perform in the database.

Which database is default in Django?

By default, the configuration uses SQLite. If you're new to databases, or you're just interested in trying Django, this is the easiest choice. SQLite is included in Python, so you won't need to install anything else to support your database.

How do I choose a database engine?

You should consider the natural structure of your data, how it is structured when you write it, and how you will read it. You will need to have an idea, or at least an opinion, about how large your data set will be, both in terms of total volume and the working sets you will need.


1 Answers

If you are going to use a relational database, the most popular in the Django community seems to be PostgreSQL. It's my personal favorite. But, MongoDB seems to be getting pretty popular in the Python/Django community as well (I have never done a project with it, though). There are a lot of successful projects out there on MySQL as well. But, I personally prefer PostgreSQL 9.0 or 9.1. Hope this helps.

EDIT: I didn't do that great of a job with this post. Just want to add a couple of more considerations.

For the vast majority of websites, either MySQL or PostgreSQL will work fine. Both have their strengths and weaknesses. I suggest you google "MySQL vs. PostgreSQL" There are a lot of hits for this search (at the time writing this, I get over 3,000,000). Here are a few tips in doing your evaluation.

  1. Give strong preference to more recent articles. Try to make sure you are comparing MySQL 5.5 to PostgreSQL 9.0 or 9.1.
  2. MySQL let's you choose your storage engine. IMO, the closes Apple to Apples comparison is InnoDB to Postgres.
  3. Keep in mind that you may not need all of the features of InnoDB or Postgres. You should also look at some of the other Storage engines.

Also, if you plan on using any triggers in your system, there a couple of really nasty bugs with MySQL and InnoDB related to them and ACID compliance. Here's the first one and here is another one. You may not need this functionality, just be aware of it.

One last thing that might make a difference to you is that with PostgreSQL you can write db functions with Python. Here is a link to the docs for this.

like image 116
David S Avatar answered Sep 22 '22 21:09

David S