Open main menu

Gramps β

Changes

GEPS 032: Database Backend API

444 bytes added, 19:15, 9 October 2023
m
See Also
{{GEPS-Finished}}
{{man menu|'''This GEP is now complete and has been implemented for [[Gramps_5.0_Wiki_Manual_-_What%27s_new%3F|Gramps 5.0]], now in github master (Aug 14, 2015).'''}}
 
This proposal defines a complete Database Backend API so that we can have plug-in replacements for BSDDB. This would allow the use of other databases.
Create a Database Backend plugin. Create a functioning BSDDB plugin, that is used by default. Identify which plugin to use via a file in the database directory.
This is underway was developed under the branch geps/gep-032-database-backend here:
https://github.com/gramps-project/gramps/tree/geps/gep-032-database-backend
 
It has now been committed to gramps50 (aka master as of this writing).
Identify the items that:
# well-defined database backend types. These could be registered, like any plugin/addon. [DONE]
# is there really any reason for Gramps to have to have the code for the db backend? All that is necessary is for the backend to create the Database instance.[DONE- Backend code is either in gramps/plugins/database or in ~/.gramps/gramps50/plugins)
It makes sense that we will reuse and share the backends, so we should use option 1, and develop a database backend plugin type.
</pre>
'''DjangoDb, DictionaryDb, and DBAPI are largely complete.'''
=== Step 3 ===
Develop a fully-tested alternative to BSDDB.
Proposal is to develop a [https://www.python.org/dev/peps/pep-0249/ DB-API 2.0 database backend], testing with sqlite, postgresql, and mysql. [MOSTLY COMPLETE]
The database directory will have a small initialize program to create the database, and return a class that can create the connection.
There still could be uses for the transactions, However. For example, we can use an abstraction for the History undo/redo. Although the current system only exists in the current session, and is limited. We can probably create a better method with more features (such as diff between versions, lifetime changes, etc).
Transactions in the Python code are ignored. '''Need to hook alternative backends to History Redo/Undo.COMPLETE'''
==Complications==
This has begun with the [http://sourceforge.net/p/gramps/source/ci/master/tree/gramps/gen/db/dictionary.py DictionaryDB] {{bug|4972}}, which is a in-memory replacement for the BSDDB. Still needs the indexes, and metadata support (gender names, bookmarks, etc). Also, the Dictionary transaction is non-existent.
Currently, the best working replacement backend is "dictionarydb". [MOSTLY COMPLETEDONE]
We can develop backends that work directly on Exported formats. Others to consider: GEDCOM and CSV. These would probably use a DbDictionary, and simply import/export on load/close (would lose data if power outage; would be fast as in-memory, slow on start/stop).
'''Branch geps/gep-032-backend-database is complete.'''
 
== Unresolved Issues ==
 
(as of May 24, 2015)
 
# dictionarydb and djangodb are not yet finished. Mostly metadata needs to be dealt with.
# dbapi using sqlite3 is largely complete.
==Other Backends==
= See Also =
* [[ExportSql.pyAddon:SQLite Export Import]]
* [[GEPS 010: Relational Backend]]
* [[GEPS 013: Gramps Webapp]]
* [[Database Backends]]
* Maillist thread: [Gramps-devel] [https://sourceforge.net/p/gramps/mailman/gramps-devel/thread/226cf688-5eba-d3a1-a971-31491541b2e2%40gramps-project.org/#msg36907575 Proposal to remove the BSDDB backend] - 23 Jan 2020
* Doug Blank YouTube channel: [https://www.youtube.com/watch?v=BoGkTypiQbA GEP-032: Gramps Database Backend API]
[[Category:GEPS|S]]
5,414
edits