Changes

Jump to: navigation, search

Database Query API

769 bytes added, 19:32, 29 January 2016
Implementation
The dotted-field path strings are mapped to SQL names by replacing dots with two underscores.
 
=== Joins ===
 
The primary_object.get_field(field-name) (and thus db.select) can also do joins across primary objects. For example consider this request:
 
>>> family.get_field("mother_handle.gramps_id", db)
'I2345'
 
That is, mother_handle is a handle to a Person, but get_field() can get the joined data, if given the database as a second argument.
 
Thus, this also works:
 
>>> db.select("Family", ["mother_handle.gramps_id"])
 
and even more complex queries, such as:
 
>>> db.select("Family", ["mother_handle.event_ref_list.ref.gramps_id"])
 
That returns all of the Event gramps_ids for all events for the mother of all families, looking something like:
 
[{"gramps_id": ["E0001", "E0002"]},
{"gramps_id": "E0003"},
{"gramps_id": ["E0003", "E0001"]},
...
]
== Speed Tests ==

Navigation menu