15,534
edits
Changes
→Getting notification of changes to the database
{{man warn|If you are a looking for documentation on how to use the Gramps system as a user instead of as a program developer, it can be found on the [[Portal:Using_Gramps|Gramps documentation web page]].}}
Explanation of the basics, underlying Gramps database. '''This is not intended to be a reference manual''', but an introductory programmer's guide to using the Gramps database access routines.
Separate [http://www.gramps-project.org/docs/ API Reference Documentation for version 45.0.x of Gramps] and as well as a simple [[Media:API.svg|UML (svg) for 4.1.x]] and [[Gramps Data Model]] overview are available.
Gramps is written in the [http://www.python.org Python] language. A basic familiarity with Python is required before the database objects can be effectively used. If you are new to Python, you may wish to check out the [https://docs.python.org/2/tutorial/ Python 2.x tutorial] or [https://docs.python.org/3/tutorial/ Python 3.x tutorial].
** '''DbWriteBase''' - virtual and implementation-independent methods for reading data ([http://sourceforge.net/p/gramps/source/ci/master/tree/gramps/gen/db//base.py gen/db/base.py])
** '''DbBsddbRead''' - read-only (accessors, getters) implementation to BSDDB databases ([http://sourceforge.net/p/gramps/source/ci/master/tree/gramps/gen/db/read.py gen/db/read.py])
*** '''DbReadBase''' - virtual and implementation-independent methods for reading data ([http://sourceforge.net/p/gramps/source/ci/master/tree/gramps/gen/db/base.py gen/db/base.py])*** '''Callback''' - callback and signal functions ([http://svn.code.sfsourceforge.net/p/gramps/codesource/ci/master/trunktree/gramps/gen/utils/callback.py gen/utils/callback.py])** '''UpdateCallback''' - callback functionality ([http://svn.code.sfsourceforge.net/p/gramps/codesource/ci/master/trunktree/gramps/gen/updatecallback.py gen/updatecallback.py])** '''DbTxn''' - class for managing Gramps transactions and the undo database ([http://sourceforge.net/p/gramps/source/ci/master/tree/gramps/gen/db//txn.py gen/db/txn.py])* '''DbDjangoDbGeneric''' - general read and write implementation to Django-based databases ([http://svn.code.sf.net/p/gramps/code/trunk/gramps/webapp/dbdjango.py webapp/dbdjango.py])implementations** '''DbWriteBase''' - virtual and implementation-independent methods for reading data ([http://sourceforge.net/p/gramps/source/ci/master/tree/gramps/gen/db//base.py gen/db/base.py])
** '''DbReadBase''' - virtual and implementation-independent methods for reading data ([http://sourceforge.net/p/gramps/source/ci/master/tree/gramps/gen/db//base.py gen/db/base.py])
=== DbBsddb ===
The DbBsddb interface defines a hierarchical database (non-relational) written in [http://www.jcea.es/programacion/pybsddb.htm PyBSDDB]. There is no such thing as a database schema, and the meaning of the data is defined in the Python classes above. The data is stored as pickled tuples and unserialized into the [[Using_database_API#Primary_Objects|primary data types (below)]]. === DB-API ===
=== Using the Database ===
For this reason, it is always necessary to have reference to the database that contains the objects with which you are working.
The handle should not be visible to the end user, and should not be included in reports or displayed on screen. Instead, the GRAMPS Gramps ID value should be used for this purpose. The GRAMPS Gramps ID is a user defined value for each object, but is not used internally to the database. This allows the user to change the GRAMPS Gramps ID without affecting the database.
Once created, the handle should never be modified.
database.connect('person-update',self.update_view)
database.connect('person-rebuild',self.update_view)
A full list of the signals that are emitted from the database can be found at the top of the <tt>[https://gramps-project.org/docs/gen/gen_db.html#module-gramps.gen.db.base GrampsDbBase]</tt> class in the <tt>GrampsDbBase[https://github.com/gramps-project/gramps/blob/master/gramps/gen/db/base.py gramps/gen/db/base.py]</tt> module.
[[Category:Developers/Tutorials]]