Changes

From Gramps

Addon:Generic DB Access lib

703 bytes added, 07:11, 13 May 2020
copied from original article - still needs to reworked and tested
=== Example ===
Here is how you would solve the above using this experimental Gramps addon:
 
<pre>
from libaccess import *
init(dbstate.db)
len([p for p in Person.all() if p.birth.date.month == 3])
</pre>
 
That’s it. Now there’s quite a bit going on here, but I think the most interesting is that this works even if a person doesn’t have a birth event, or if the birth event happens to be missing (eg, the database is in an inconsistent state). By allowing this, it makes chained accessors (item.item.item) possible to use to get to the endpoint to make the comparison (month == 3). Also, one doesn’t need to know anything about the database or gen.lib objects other than the field names we’re interested in.
==See also==
15,091
edits

Navigation menu