Django is an open-source and free web application framework that is originally written in Python. The main purpose of Django is to ease the complexities in creation of database-driven websites. It supports four database backends-Sqlite, Oracle, MySQL, and PostgreSQL. In this tutorial we will learn how Sqlite in Django works
Django uses Sqlite for its configuration by default. Since Sqlite is installed in Python, you do not need to install it separately for supporting your database. The database keys used are:
Transactions in Django are atomic and they can be further broken into smaller transactions referred to as SavePoints. SavePoints can also be known as partial transactions. Consider that you have a transaction that needs four SQL steps to run. In such a case, you can create a SavePoint after two steps.Once this SavePoint is created, you can do a partial rollback even if the transaction fails due to failure of third and fourth steps. This will enable you to get rid of the third and the fourth steps, without compromising with the first two steps.Thus, SavePoints enables the users to split a transaction into smaller transactions in order to do partial rollback in case of transaction failure at some point.
All the Sqlite versions, after Sqlite 3.6.8, support SavePoints. However, due to a certain flaw in the design of sqlite3, these SavePoints cannot be used at a high level.In Sqlite, when autocommit is enabled, SavePoints are rendered useless.In addition, when the autocommit is disabled, sqlite3 commits transactions before the SavePoints.Thus, this bug leads to following results:
Conclusion
Sqlite and Django work efficiently together in small-scale web applications that run on a single machine. In addition, no data gets lost in large transactions and no data is lost in any moderate write activities. However, when multiple servers are run or a server-based database is used, Sqlite faces troubles when it is run over a network file system.