This page documents the new backend infrastructure introduced in Gramps 5.0.
Beginning with the Gramps 5.1 version, SQLite is the default database engine and uses the DB-API 2.0 backend.
When originally written in the early 2000s, Gramps used XML for data storage. Beginning with Gramps 2.0, it was changed to use the Berkeley Software Distribution database (also known as BSDDB or Berkeley db) and its Python bindings. At the time, there were not that many choices database supporting hierarchical structures... which Gramps needs.
The BSDDB system is very sophisticated; however, it requires that all of the details be manually handled. Although this is quite powerful, it does take a high level of skill.
A serious problem with the BSDDB system is that the internal system can change with a system upgrade. That means that you may not be able to open your database after a system upgrade.
Another problem with the BSDDB system is that it is very easy to corrupt the databases. This was the strongest reason for moving to SQLite.
Finally, the way that Gramps uses BSDDB prevents users from being able to have multiple simultaneous users. This makes the BSDDB unsuitable for a collaborative website, for example.
For these reasons, it was decided to create a level of abstraction such that we can use different databases but keep the core Gramps code the same. This was designed in GEPS 032: Database Backend API and implemented in 2015.
See the Database Formats documentation for more specific information about the evolution of how Gramps uses databases.
When the Gramps database backend extensibility was introduced in 2019, there were 4 different database backends provided for performance evaluation. These are described below.
As described above, the Berkeley DB (BSDDB) is the standard Gramps database. All internal databases prior to Gramps 5.0 were of this type, although the version and low-level details have continued to evolve and change over the last 10 years.
DB-API 2.0 Backend
This API was defined in Python's PEP-0249. It defines a simple interface to run SQL commands, and return their results. Some common database engines implement this API, including:
Other implementations of DB-API 2.0 are listed here: https://wiki.python.org/moin/DbApiModuleComparison
DB-API 2.0 describes an interface using SQL; however, Gramps does not use SQL in a typical relational database style. The SQL tables are used as a "data store" where your Gramps data is stored as serialized (ie, "pickled") blobs. This keeps the data in a hierarchical structure, but allows any DB-API 2.0 database to be used as the data store.
The DictionaryDB is an "in-memory" database, meaning that, while processing, all data only exists in your computer's RAM (volatile memory). That is, if the power went out during an editing session, all of your recent work would be lost. However, DictionaryDB is very fast.
DictionaryDB saves your data on exiting Gramps, and will re-load it when opening your Family Tree.
The DjangoDB is used for the Gramps collaborative web application, Gramps Connect. This is a relational database system, and, as such, is not a good match for Gramps' hierarchical code. However, it can be used.