Changes

Jump to: navigation, search

Using database API

16 bytes added, 13:29, 1 March 2007
fix api links
===Transactions and Commits===
In order to support an UNDO feature, the database has the concept of [http://developerswww.gramps-project.org/devdoc/api/public2.2/GrampsDbBaseprivate/GrampsDb._GrampsDbBase.Transaction-class.html Transactions].
Transactions are a group of related database commit operations that need treated as a single unit. If all related commits are not undone as a single unit, the database can be left in a corrupted state. The UNDO operation will undo all the commits in the transaction.
for handle in database.get_person_handles():
person = database.get_person_from_handle(handle)
A more efficient method exists, but is more complicated to use. The database can provide a [http://developerswww.gramps-project.org/devdoc/api/public2.2/GrampsDbBaseprivate/GrampsDb._GrampsDbBase.GrampsCursor-class.html cursor] that will iterate through the database without having to load all handles into memory. The cursor returns a handle, data pair. The data represents the serialized data directly from the database. It is the users responsibility to unserialize the data. An example is below:
cursor = database.get_person_cursor()
pair = cursor.first()
35
edits

Navigation menu