[Answered ]-Database engine choice for Django/ Python application

1👍

I think it depends on your requirements and that is a question only you can answer. I think the notion that it is easier to setup is silly. You are software professionals, use what works, learn the tools. On ubuntu, setting up a dev postgres is pretty much an app-get away for instance.

The very first question you should ask is SQL a good fit for what we are doing at all? If not, use something else (though you may want to choose something other than Django, and I say this as a Django-non-rel heavy user), if so, continue.

The good thing is that in Django, if you really don’t want to setup Postgres for use in your development environment, you can simply use your settings files to swap database types between environments such as dev and production. That of course assumes that you are not doing anything Postgres specific in Django, i.e. you are simply using the ORM and features/libraries in Django that are not database specific. In your case, this doesn’t sound like it would be an issue.

Disclaimer: I strongly suggest though you test heavily on Postgres if you are also using SQLite in dev. You never know what integration issues can pop-up and certainly the performance characteristics are dramatically different. If it makes you feel better, Google themselves in the Google App Engine SDK for example uses SQLite to simulate the App Engine datastore at dev time.

Anyway, first, ready SQLite official use-cases claims. Moreover, see the implementation limits and see if any will cause problems for your requirements.

General SQLite Pros:

  • Easy to setup, light-weight, more of a single-user or low volume database
  • Can be embedded into other applications easily, for example a game
  • Portable
  • Fast enough, gets the job done
  • Simple cases like a small system or replacing direct disk access

Postgres is a much more robust database that is designed to support a variety of different size applications that benefit from using a relational database. Generally it has almost all the features of SQLite and many more, but is obviously harder to setup, is not really designed to be quickly embedded, and is a bit less portable. In other words, not so lite 🙂

Have a look at this features matrix for Postgres.

Here is a more direct comparison in one place.

General Postgres Pros:

  • Designed to be multi-user
  • Lots of useful tools in the chain including things like backup and replication
  • Comprehensive feature set for data types, operations running inside the DB like procedures, etc.
  • Can scale decently if you are competent in SQL and using SQL for the right reasons.
  • ACID compliance and transactions are stressed and fully implemented

;tldr – Use Postgres if you want to plan for the long-term and feel confident. If you don’t care, use SQLite if you must. Enjoy the best of both worlds if you want by using Django to switch databases via settings as long as you don’t do anything DB specific.

1👍

use postgreSQL, our team worked with sqlite3 for a long time. However, when you import data to db,it often give the information ‘database is locked!’

The advantages of sqlite3

  1. it is small,as you put it, no server setup needed

  2. max_length in models.py is not strictly, you set max_length=10, if you put 100 chars in the field, sqlite3 never complain about it,and never truncate it.

but postgreSQL is faster than sqlite3, and if you use sqlite3.
some day you want to migrate to postgreSQL, It is a matter beacuse sqlite3 never truncate string but postgreSQL complains about it!

Leave a comment