Gramps Database API.
Access to the database is made through Python classes. Exactly what functionality you have is dependent on the properties of the database. For example, if you are accessing a read-only view, then you will only have access to a subset of the methods available.
At the root of any database interface is either DbReadBase and/or DbWriteBase. These define the methods to read and write to a database, respectively.
The full database hierarchy is:
The DbBsddb interface defines a hierarchical database (non-relational) written in 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 primary data types (below).
The DbDjango interface defines the Gramps data in terms of models and relations from the Django project. The database backend can be any implementation that supports Django, including such popular SQL implementations as sqlite, MySQL, Postgresql, and Oracle. The data is retrieved from the SQL fields, serialized and then unserialized into the primary data types (below).
More details can be found in the manual’s Using database API.
Base class for the Gramps databases. All database interfaces should inherit from this class.
Bases: object
Gramps database object. This object is a base class for all database interfaces. All methods raise NotImplementedError and must be implemented in the derived class as required.
Find all objects that hold a reference to the object handle.
Returns an iterator over a list of (class_name, handle) tuples.
Parameters: |
|
---|
This default implementation does a sequential scan through all the primary object databases and is very slow. Backends can override this method to provide much faster implementations that make use of additional capabilities of the backend.
Note that this is a generator function, it returns a iterator for use in loops. If you want a list of the results use:
result_list = list(find_backlink_handles(handle))
Return the next available Gramps ID for a Event object based off the event ID prefix.
Return the next available Gramps ID for a Family object based off the family ID prefix.
Return the next available Gramps ID for a Note object based off the note ID prefix.
Return the next available Gramps ID for a MediaObject object based off the media object ID prefix.
Return the next available Gramps ID for a Person object based off the person ID prefix.
Return the next available Gramps ID for a Place object based off the place ID prefix.
Return the next available Gramps ID for a Repository object based off the repository ID prefix.
Return the next available Gramps ID for a Source object based off the source ID prefix.
Return a list of all child reference types associated with Family instances in the database.
Find a Citation in the database from the passed Gramps ID.
If no such Citation exists, None is returned. Needs to be overridden by the derived class.
Find a Citation in the database from the passed Gramps ID.
If no such Citation exists, None is returned.
Return a list of database handles, one handle for each Citation in the database.
If sort_handles is True, the list is sorted by Citation title.
Return a list of all Attribute types assocated with Event instances in the database.
Find an Event in the database from the passed Gramps ID.
If no such Event exists, None is returned. Needs to be overridden by the derived class.
Find a Event in the database from the passed Gramps ID.
If no such Event exists, None is returned.
Return a list of database handles, one handle for each Event in the database.
Return a list of all custom event role names associated with Event instances in the database.
Return a list of all Attribute types associated with Family instances in the database.
Find a Family in the database from the passed Gramps ID.
If no such Family exists, None is returned. Need to be overridden by the derived class.
Find a Family in the database from the passed Gramps ID.
If no such Family exists, None is returned.
Return a list of database handles, one handle for each Family in the database.
Return a list of all relationship types associated with Family instances in the database.
Databases can implement certain features or not. The default is None, unless otherwise explicitly stated.
Return unserialized data from database given handle and object class
Return a list of all Attribute types associated with Media and MediaRef instances in the database.
Return a list of database handles, one handle for each MediaObject in the database.
If sort_handles is True, the list is sorted by title.
Return the defined names that have been assigned to a default grouping.
Return a list of all custom names types associated with Person instances in the database.
Find a Note in the database from the passed Gramps ID.
If no such Note exists, None is returned. Needs to be overridden by the derived classderri.
Find a Note in the database from the passed Gramps ID.
If no such Note exists, None is returned.
Return a list of database handles, one handle for each Note in the database.
Return a list of all custom note types associated with Note instances in the database.
Return the number of media objects currently in the database.
Return the number of source repositories currently in the database.
Return the number of tags currently in the database.
Find a MediaObject in the database from the passed Gramps ID.
If no such MediaObject exists, None is returned. Needs to be overridden by the derived class.
Find an Object in the database from the passed Gramps ID.
If no such Object exists, None is returned.
Return a list of all custom origin types associated with Person/Surname instances in the database.
Return a list of all Attribute types associated with Person instances in the database.
Find a Person in the database from the passed Gramps ID.
If no such Person exists, None is returned. Needs to be overridden by the derived class.
Find a Person in the database from the passed Gramps ID.
If no such Person exists, None is returned.
Return a list of database handles, one handle for each Person in the database.
If sort_handles is True, the list is sorted by surnames.
Find a Place in the database from the passed Gramps ID.
If no such Place exists, None is returned. Needs to be overridden by the derived class.
Find a Place in the database from the passed Gramps ID.
If no such Place exists, None is returned.
Return a list of database handles, one handle for each Place in the database.
If sort_handles is True, the list is sorted by Place title.
Return a list of all custom place types assocated with Place instances in the database.
Return raw (serialized and pickled) Citation object from handle
Return raw (serialized and pickled) Repository object from handle
Returns a reference to a cursor over the reference map primary map
Returns a reference to a cursor over the reference map referenced map
Find a Repository in the database from the passed Gramps ID.
If no such Repository exists, None is returned. Needs to be overridden by the derived class.
Find a Repository in the database from the passed Gramps ID.
If no such Repository exists, None is returned.
Return a list of database handles, one handle for each Repository in the database.
Return a list of all custom repository types associated with Repository instances in the database.
Return the Researcher instance, providing information about the owner of the database.
Return a list of all Attribute types associated with Source/Citation instances in the database.
Find a Source in the database from the passed Gramps ID.
If no such Source exists, None is returned. Needs to be overridden by the derived class.
Find a Source in the database from the passed Gramps ID.
If no such Source exists, None is returned.
Return a list of database handles, one handle for each Source in the database.
If sort_handles is True, the list is sorted by Source title.
Return a list of all custom source media types associated with Source instances in the database.
Find a Tag in the database from the passed handle.
If no such Tag exists, None is returned.
Find a Tag in the database from the passed Tag name.
If no such Tag exists, None is returned. Needs to be overridden by the derived class.
Return a list of database handles, one handle for each Tag in the database.
If sort_handles is True, the list is sorted by Tag name.
Return a list of all custom names types associated with Url instances in the database.
Returns True if the key exists in table given a table name
Not used in current codebase
Return True if the handle exists in the current MediaObjectdatabase.
Return True if the handle exists in the current Repository database.
Return an iterator over objects for Tags in the database
Open the specified database.
Notify clients that the data has changed significantly, and that all internal data dependent on the database should be rebuilt. Note that all rebuild signals on all objects are emitted at the same time. It is correct to assume that this is always the case.
Todo
it might be better to replace these rebuild signals by one single database-rebuild signal.
Set the naming template for Gramps Event ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as E%d or E%04d.
Set the naming template for Gramps Family ID values. The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as F%d or F%04d.
Set the naming template for Gramps Note ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as N%d or N%04d.
Set the naming template for Gramps MediaObject ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as O%d or O%04d.
Set the naming template for Gramps Person ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as I%d or I%04d.
Set the naming template for Gramps Place ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as P%d or P%04d.
Set the prefixes for the gramps ids for all gramps objects
Define the callback function that is called whenever an redo operation is executed.
The callback function receives a single argument that is a text string that defines the operation.
Set the naming template for Gramps Repository ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as R%d or R%04d.
Set the naming template for Gramps Source ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as S%d or S%04d.
Bases: gramps.gen.db.base.DbReadBase
Gramps database object. This object is a base class for all database interfaces. All methods raise NotImplementedError and must be implemented in the derived class as required.
Adds a child to a family.
Add an Event to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Family to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Note to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a MediaObject to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Person to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Place to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Repository to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Source to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Tag to the database, assigning a handle if it has not already been defined.
Add surname from given person to list of surnames
Commit the specified object to the database, storing the changes as part of the transaction.
Commit the specified Event to the database, storing the changes as part of the transaction.
Commit the specified Family to the database, storing the changes as part of the transaction.
Commit the specified MediaObject to the database, storing the changes as part of the transaction.
Commit the specified Note to the database, storing the changes as part of the transaction.
Commit the specified Person to the database, storing the changes as part of the transaction.
Commit the specified Place to the database, storing the changes as part of the transaction.
Commit the specified Repository to the database, storing the changes as part of the transaction.
Commit the specified Source to the database, storing the changes as part of the transaction.
Commit the specified Tag to the database, storing the changes as part of the transaction.
Deletes a person from the database, cleaning up all associated references.
Called each time an object is removed from the database.
This can be used by subclasses to update any additional index tables that might need to be changed.
Remove a person as a child of the family, deleting the family if it becomes empty.
Remove the Event specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove the Family specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove a family and its relationships.
Check whether there are persons with the same surname left in the database.
If not then we need to remove the name from the list. The function must be overridden in the derived class.
Remove the Note specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove the MediaObjectPerson specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove a person as either the father or mother of a family, deleting the family if it becomes empty.
Remove the Person specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove the Place specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove the Repository specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove the Source specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Remove the Tag specified by the database handle from the database, preserving the change in the passed transaction.
This method must be overridden in the derived class.
Set the default grouping name for a surname.
Needs to be overridden in the derived class.
Sort the list of surnames contained in the database by locale ordering.
Revert the changes made to the database so far during the transaction.
Prepare the database for the start of a new transaction.
Two modes should be provided: transaction.batch=False for ordinary database operations that will be encapsulated in database transactions to make them ACID and that are added to Gramps transactions so that they can be undone. And transaction.batch=True for lengthy database operations, that benefit from a speedup by making them none ACID, and that can’t be undone. The user is warned and is asked for permission before the start of such database operations.
Parameters: | transaction (DbTxn) – Gramps transaction ... |
---|---|
Returns: | Returns the Gramps transaction. |
Return type: | DbTxn |
Make the changes to the database final and add the content of the transaction to the undo database.
Read classes for the Gramps databases.
Bases: gramps.gen.db.base.DbReadBase, gramps.gen.utils.callback.Callback
Read class for the Gramps databases. Implements methods necessary to read the various object classes. Currently, there are nine (9) classes:
Person, Family, Event, Place, Source, Citation, MediaObject, Repository and Note
For each object class, there are methods to retrieve data in various ways. In the methods described below, <object> can be one of person, family, event, place, source, media_object, respository or note unless otherwise specified.
returns an object given its handle
returns an object given its gramps id
returns a cursor over an object. Example use:
with get_person_cursor() as cursor:
for handle, person in cursor:
# process person object pointed to by the handle
returns a list of handles for the object type, optionally sorted (for Person, Place, Source and Media objects)
returns an iterator that yields one object handle per call.
returns an iterator that yields one object per call. The objects available are: people, families, events, places, sources, media_objects, repositories and notes.
returns a list of all Event types assocated with instances of <object> in the database.
returns a list of all Event types assocated with instances of <object> in the database.
return all the keys of a database table
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Close the specified database.
The method needs to be overridden in the derived class.
Find all objects that hold a reference to the object handle.
Returns an interator over alist of (class_name, handle) tuples.
Parameters: |
|
---|
This default implementation does a sequencial scan through all the primary object databases and is very slow. Backends can override this method to provide much faster implementations that make use of additional capabilities of the backend.
Note that this is a generator function, it returns a iterator for use in loops. If you want a list of the results use:
result_list = list(find_backlink_handles(handle))
Return the next available Gramps ID for a Source object based off the source ID prefix.
Return the next available Gramps ID for a Event object based off the event ID prefix.
Return the next available Gramps ID for a Family object based off the family ID prefix.
Return the next available Gramps ID for a Note object based off the note ID prefix.
Return the next available Gramps ID for a MediaObject object based off the media object ID prefix.
Return the next available Gramps ID for a Person object based off the person ID prefix.
Return the next available Gramps ID for a Place object based off the place ID prefix.
Return the next available Gramps ID for a Respository object based off the repository ID prefix.
Return the next available Gramps ID for a Source object based off the source ID prefix.
Return a list of all child reference types assocated with Family instances in the database.
Find a Citation in the database from the passed Gramps ID.
If no such Citation exists, None is returned.
Find a Citation in the database from the passed handle.
If no such Citation exists, None is returned.
Return a list of database handles, one handle for each Citation in the database.
If sort_handles is True, the list is sorted by Citation Volume/Page.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
In BSDDB, we use the file directory name as the unique ID for this database on this computer.
Return a list of all Attribute types assocated with Event instances in the database.
Find an Event in the database from the passed Gramps ID.
If no such Family exists, None is returned.
Find a Event in the database from the passed handle.
If no such Event exists, None is returned.
Return a list of database handles, one handle for each Event in the database.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return a list of all custom event role names assocated with Event instances in the database.
Return a list of all Attribute types assocated with Family instances in the database.
Find a Family in the database from the passed Gramps ID.
If no such Family exists, None is return.
Find a Family in the database from the passed handle.
If no such Family exists, None is returned.
Return a list of database handles, one handle for each Family in the database.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return a list of all relationship types assocated with Family instances in the database.
Returns a gen.lib object (or None) given table_name and Gramps ID.
Examples:
>>> self.get_from_name_and_gramps_id("Person", "I00002")
>>> self.get_from_name_and_gramps_id("Family", "F056")
>>> self.get_from_name_and_gramps_id("Media", "M00012")
Returns a gen.lib object (or None) given table_name and handle.
Examples:
>>> self.get_from_name_and_handle("Person", "a7ad62365bc652387008")
>>> self.get_from_name_and_handle("Media", "c3434653675bcd736f23")
Return a list of all Attribute types assocated with Media and MediaRef instances in the database.
Return a list of database handles, one handle for each MediaObject in the database.
If sort_handles is True, the list is sorted by title.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return the defined names that have been assigned to a default grouping.
Return the default grouping name for a surname. Return type is a unicode object
Return a list of all custom names types assocated with Person instances in the database.
Find a Note in the database from the passed Gramps ID.
If no such Note exists, None is returned.
Find a Note in the database from the passed handle.
If no such Note exists, None is returned.
Return a list of database handles, one handle for each Note in the database.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return a list of all custom note types assocated with Note instances in the database.
Return the number of media objects currently in the database.
Return the number of source repositories currently in the database.
Return the number of tags currently in the database.
Find a MediaObject in the database from the passed Gramps ID.
If no such MediaObject exists, None is returned.
Find an Object in the database from the passed handle.
If no such Object exists, None is returned.
Return a list of all custom origin types assocated with Person/Surname instances in the database.
Return a list of all Attribute types assocated with Person instances in the database.
Find a Person in the database from the passed Gramps ID.
If no such Person exists, None is returned.
Find a Person in the database from the passed handle.
If no such Person exists, None is returned.
Return a list of database handles, one handle for each Person in the database.
If sort_handles is True, the list is sorted by surnames.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Find a Place in the database from the passed Gramps ID.
If no such Place exists, None is returned.
Find a Place in the database from the passed handle.
If no such Place exists, None is returned.
Return a list of database handles, one handle for each Place in the database.
If sort_handles is True, the list is sorted by Place title.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return a list of all custom place types assocated with Place instances in the database.
Find a Repository in the database from the passed Gramps ID.
If no such Repository exists, None is returned.
Find a Repository in the database from the passed handle.
If no such Repository exists, None is returned.
Return a list of database handles, one handle for each Repository in the database.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return a list of all custom repository types assocated with Repository instances in the database.
Return the Researcher instance, providing information about the owner of the database.
Return a list of all Attribute types assocated with Source/Citation instances in the database.
Find a Source in the database from the passed Gramps ID.
If no such Source exists, None is returned.
Find a Source in the database from the passed handle.
If no such Source exists, None is returned.
Return a list of database handles, one handle for each Source in the database.
If sort_handles is True, the list is sorted by Source title.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return a list of all custom source media types assocated with Source instances in the database.
Find a Tag in the database from the passed handle.
If no such Tag exists, None is returned.
Find a Tag in the database from the passed Tag name.
If no such Tag exists, None is returned.
Return a list of database handles, one handle for each Tag in the database.
If sort_handles is True, the list is sorted by Tag name.
Warning
For speed the keys are directly returned, so on python3 bytestrings are returned! Use constfunc.py handle2internal on this result!
Return a list of all custom names types assocated with Url instances in the database.
Return True if the handle exists in the current Citation database.
Return True if the handle exists in the current MediaObjectdatabase.
Return True if the handle exists in the current Repository database.
Notify clients that the data has changed significantly, and that all internal data dependent on the database should be rebuilt.
Set the naming template for Gramps Citation ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as C%d or C%04d.
Set the naming template for Gramps Event ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as E%d or E%04d.
Set the naming template for Gramps Family ID values. The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as F%d or F%04d.
Set the naming template for Gramps Note ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as N%d or N%04d.
Set the naming template for Gramps MediaObject ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as O%d or O%04d.
Set the naming template for Gramps Person ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as I%d or I%04d.
Set the naming template for Gramps Place ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as P%d or P%04d.
Define the callback function that is called whenever an redo operation is executed.
The callback function receives a single argument that is a text string that defines the operation.
Set the naming template for Gramps Repository ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as R%d or R%04d.
Set the naming template for Gramps Source ID values.
The string is expected to be in the form of a simple text string, or in a format that contains a C/Python style format string using %d, such as S%d or S%04d.
Creating a surname from raw data of a person, to use for sort and index returns a byte string
Provide the Berkeley DB (DbBsddb) database backend for Gramps. This is used since Gramps version 3.0
Bases: gramps.gen.db.read.DbBsddbRead, gramps.gen.db.base.DbWriteBase, gramps.gen.updatecallback.UpdateCallback
Gramps database write access object.
Add a Citation to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add an Event to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Family to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Note to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a MediaObject to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Person to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Place to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Repository to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Source to the database, assigning internal IDs if they have not already been defined.
If not set_gid, then gramps_id is not set.
Add a Tag to the database, assigning a handle if it has not already been defined.
Build surname list for use in autocompletion This is a list of unicode objects, which are decoded from the utf-8 in bsddb
Decorator function for catching database errors. If func throws one of the exceptions in DBERRS, the error is logged and a DbError exception is raised.
Commit the specified object to the database, storing the changes as part of the transaction.
Commit the specified Citation to the database, storing the changes as part of the transaction.
Commit the specified Event to the database, storing the changes as part of the transaction.
Commit the specified Family to the database, storing the changes as part of the transaction.
Commit the specified MediaObject to the database, storing the changes as part of the transaction.
Commit the specified Note to the database, storing the changes as part of the transaction.
Commit the specified Person to the database, storing the changes as part of the transaction.
Commit the specified Place to the database, storing the changes as part of the transaction.
Commit the specified Repository to the database, storing the changes as part of the transaction.
Commit the specified Source to the database, storing the changes as part of the transaction.
Commit the specified Tag to the database, storing the changes as part of the transaction.
Remove all references to the primary object from the reference_map. handle should be utf-8
Find all objects that hold a reference to the object handle.
Returns an interator over a list of (class_name, handle) tuples.
Parameters: |
|
---|
Note that this is a generator function, it returns a iterator for use in loops. If you want a list of the results use:
result_list = list(find_backlink_handles(handle))
Find all child places having the given place as the primary parent.
In BSDDB, we use the file directory name as the unique ID for this database on this computer.
Returns a reference to a cursor over the place parents
Returns a reference to a cursor over the reference map
Returns a reference to a cursor over the reference map primary map
Returns a reference to a cursor over the reference map referenced map
Reindex all primary records in the database.
This will be a slow process for large databases.
Remove the Citation specified by the database handle from the database, preserving the change in the passed transaction.
Remove the Event specified by the database handle from the database, preserving the change in the passed transaction.
Remove the Family specified by the database handle from the database, preserving the change in the passed transaction.
Check whether there are persons with the same surname left in the database.
If not then we need to remove the name from the list. The function must be overridden in the derived class.
Remove the Note specified by the database handle from the database, preserving the change in the passed transaction.
Remove the MediaObjectPerson specified by the database handle from the database, preserving the change in the passed transaction.
Remove the Person specified by the database handle from the database, preserving the change in the passed transaction.
Remove the Place specified by the database handle from the database, preserving the change in the passed transaction.
Remove the Repository specified by the database handle from the database, preserving the change in the passed transaction.
Remove the Source specified by the database handle from the database, preserving the change in the passed transaction.
Remove the Tag specified by the database handle from the database, preserving the change in the passed transaction.
Revert the changes made to the database so far during the transaction.
Prepare the database for the start of a new Transaction.
Supported transaction parameters:
Make the changes to the database final and add the content of the transaction to the undo database.
return id for association of secondary index. returns a byte string
return handle for association of indexes returns byte string
return handle for association of indexes returns byte string
Bases: object
Provide a basic iterator that allows the user to cycle through the elements in a particular map.
A cursor should never be directly instantiated. Instead, in should be created by the database class.
A cursor should only be used for a single pass through the database. If multiple passes are needed, multiple cursors should be used.
Issue DBCursor get call (with DB_RMW flag if update requested) Return results to caller
Issue DBCursor get call (with DB_RMW flag if update requested) Return results to caller
Issue DBCursor get call (with DB_RMW flag if update requested) Return results to caller
Issue DBCursor get call (with DB_RMW flag if update requested) Return results to caller
Issue DBCursor get call (with DB_RMW flag if update requested) Return results to caller
BSDDBTxn class: Wrapper for BSDDB transaction-oriented methods
Bases: object
Wrapper for BSDDB methods that set up and manage transactions. Implements context management functionality allowing constructs like:
and other transaction-oriented DB access methods, where “env” is a BSDDB DBEnv object and “DB” is a BSDDB database object.
Transactions are automatically begun when the “with” statement is executed and automatically committed when control flows off the end of the “with” statement context, either implicitly by reaching the end of the indentation level or explicity if a “return” statement is encountered or an exception is raised.
Flush the underlying memory pool, write a checkpoint record to the log and then flush the log
Release all the per-process resources associated with the specified transaction, neither committing nor aborting the transaction
Returns the primary key, given the secondary one, and associated data
Returns a list of tuples (GID, TXN) of transactions prepared but still unresolved
Exports the DbTxn class for managing Gramps transactions and the undo database.
Bases: collections.defaultdict
Define a group of database commits that define a single logical operation.
Add a commit operation to the Transaction.
The obj_type is a constant that indicates what type of PrimaryObject is being added. The handle is the object’s database handle, and the data is the tuple returned by the object’s serialize method.
Return the text string that describes the logical operation performed by the Transaction.
Return a list of record numbers associated with the transaction.
While the list is an arbitrary index of integers, it can be used to indicate record numbers for a database.
Return a tuple representing the PrimaryObject type, database handle for the PrimaryObject, and a tuple representing the data created by the object’s serialize method.
Set the text string that describes the logical operation performed by the Transaction.
Exports the DbUndo class for managing Gramps transactions undos and redos.
Bases: object
Base class for the Gramps undo/redo manager. Needs to be subclassed for use with a real backend.
Commit the transaction to the undo/redo database. “txn” should be an instance of Gramps transaction class
Helper method to undo/redo the changes made
Bases: gramps.gen.db.undoredo.DbUndo
Class constructor for Gramps undo/redo database using a bsddb recno database as the backing store.
Bases: gramps.gen.db.undoredo.DbUndo
Implementation of the Gramps undo database using a Python list
Declare constants used by database modules
Exceptions generated by the Db package.
Bases: exceptions.Exception
Error used to report that the Berkeley database used to create the family tree is of a version that is too new to be supported by the current version.
Bases: exceptions.Exception
Error used to report that the Berkeley database used to create the family tree is of a version that is newer than the current version, but it may be possible to open the tree, because the difference is only a point upgrade (i.e. a difference in the last digit of the version tuple).
Bases: exceptions.Exception
Error used to report that the Berkeley database used to create the family tree is of a version that is too new to be supported by the current version.
Bases: exceptions.Exception
Error used to report that the database ‘environment’ could not be opened. Most likely, the database was created by a different version of the underlying database engine.
Bases: exceptions.Exception
Error used to indicate that a transaction needs to be canceled, for example becuase it is lengthy and the users requests so.
Bases: exceptions.Exception
Error used to report that a database needs to be upgraded before it can be used.
Bases: exceptions.Exception
Error used to report that a file could not be read because it is written in an unsupported version of the file format.
Bases: exceptions.Exception
Error used to indicate that a write to a database has failed.
Bases: exceptions.Exception
Error used to report that the Python version used to create the family tree (i.e. Python3) is of a version that is newer than the current version (i.e.Python2), so the Family Tree cannot be opened
Bases: exceptions.Exception
Error used to report that the Python version used to create the family tree (i.e. Python2) is earlier than the current Python version (i.e. Python3), so the Family Tree needs to be upgraded..
methods to upgrade a database from version 13 to current version
Convert location base to include an empty locality field.
Upgrade database from version 14 to 15. This upgrade adds:
- tagging
- surname list
- remove marker
Upgrade database from version 15 to 16. This upgrade converts all SourceRef child objects to Citation Primary objects.
For each primary object that has a sourceref, what we have to do is:
- create each citation
- update the object to reference the Citations
- remove backlinks for references from object to Source
- add backlinks for references from object to Citations
- add backlinks for references from Citation to Source
the backlinks are all updated at the end by calling reindex_reference_map
Upgrade database from version 16 to 17.
This module Provides backup and restore functions for a database. The backup function saves the data into backup files, while the restore function loads the data back into a database.
You should only restore the data into an empty database.
Not all of the database tables need to be backed up, since many are automatically generated from the others. The tables that are backed up are the primary tables and the metadata table.
The database consists of a table of “pickled” tuples. Each of the primary tables is “walked”, and the pickled tuple is extracted, and written to the backup file.
Restoring the data is just as simple. The backup file is parsed an entry at a time, and inserted into the associated database table. The derived tables are built automatically as the items are entered into db.
Exports the database to a set of backup files. These files consist of the pickled database tables, one file for each table.
The heavy lifting is done by the private __do__export() function. The purpose of this function is to catch any exceptions that occur.
Parameters: | database (DbDir) – database instance to backup |
---|
Restores the database to a set of backup files. These files consist of the pickled database tables, one file for each table.
The heavy lifting is done by the private __do__restore() function. The purpose of this function is to catch any exceptions that occur.
Parameters: | database (DbDir) – database instance to restore |
---|