1,583
edits
Changes
→Examples
{{Third-party plugin}}
The Query Gramplet takes SQL-like queries and produces a Quick View.
= Examples =
The QueryGramplet in gramps-addons/trunk for gramps/master Gramps 5.0 can now SELECT, UPDATE, and DELETE. Some examples (keywords are showncapitalized, but the SQL parser is case-insensitive; fields that are capitalized are ''macros''and must be capitalized, see below for more information): <pre>DELETE FROM person WHERE GIVEN == "Travis"; SELECT * FROM person LIMIT 10;
This API is made possible through the generic struct/json interface. It is very little code, because it relies on these generic structures. It should be able to be made solid enough to expose to users (say as a generic filter). The parser can be made more user friendly... it may just throw an error currently.
Here is the grammar for the subset of SQL supported. The SELECT, UPDATE, DELETE, and LIMIT clauses may be in any order. The WHERE clause (if used) must be last.
<pre>
SELECT expr1 [as var1][, expr2 [as var2], ...] FROM table [LIMIT number1[, number2]] [WHERE expression];
... [RAW | NORAW] ...
</pre>
'''table''' is one of:
Examples:
<pre> SELECT gramps_id, primary_name.surname_list.surname FROM person WHERE any([re.match("Sm.*th", name) for name in col[1]]);</pre>
Searches all primary_name surnames to find names that start with "Sm" and end in "th". col[1] is primary_name.surname_list.surname, which is a list of surnames.
[[Image:QuerySmith.png|thumb|left|400px]]
{{-}}
<pre> $ select given_name, surname from people;
$ select * from families;
</pre>
[[Category:Plugins]]
[[Category:Developers/General]]
[[Category:Reports]]
[[Category:Gramplets]]
[[Category:Views]]