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?
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With