Skip to main content

gramps-object-query-language

A small, closed query AST and SQL compiler for fast object queries against Gramps genealogy data.

This is not a general query language, not GraphQL, and not a raw-SQL passthrough. It compiles a structured Query (select/where/order_by/ limit/after) -- or an "almost Python" expression string -- into parameterized SQL against Gramps' flattened secondary columns, with every column checked against a fixed per-type whitelist before the compiler ever touches it.

It is standalone and privacy-agnostic: it carries no knowledge of proxies, permissions, or any particular web API. An evaluator/proxied_query path is also included for evaluating the same query AST directly against real (possibly proxied) Gramps objects, for callers that can't run raw SQL against an unproxied database.

Install

pip install gramps-object-query-language

Documentation

  • README-query-language.md -- a plain-language, goal-first guide to where_expr for non-programmers ("Find all the families where the mom died before the dad" -> the query for it).
  • docs/where_expr.md -- the technical reference for the "almost Python" where_expr filter language (Person "gender == Person.MALE", Family "mother.death.date.sortval < father.death.date.sortval", ...), with every example tested against real SQLite.

Modules

  • gramps_object_query_language.query -- the query AST and SQL compiler.
  • gramps_object_query_language.query_lang -- an "almost Python" expression parser (parse_expr) that translates into the same where shape, plus compile_expr, which translates it the rest of the way into query.py's executable AST for callers that want to run it directly. See docs/where_expr.md.
  • gramps_object_query_language.evaluator -- evaluates the AST directly against real Gramps objects (no SQL), for use with a proxied database.
  • gramps_object_query_language.proxied_query -- runs a where expression through Gramps' own Filter/Rule machinery against a possibly-proxied database.

Development

pip install -e ".[test]"
pytest

License

GNU Affero General Public License v3 or later (AGPL-3.0-or-later). See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gramps_object_query_language-0.3.1.tar.gz (56.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gramps_object_query_language-0.3.1-py3-none-any.whl (59.8 kB view details)

Uploaded Python 3

File details

Details for the file gramps_object_query_language-0.3.1.tar.gz.

File metadata

File hashes

Hashes for gramps_object_query_language-0.3.1.tar.gz
Algorithm Hash digest
SHA256 81dfd24ca73460dc0f87933788f9a2a8a4b68ba982f981e6d9797f602ba6488c
MD5 4b40b786537b013835b429e4e11c399b
BLAKE2b-256 9cc32d04af56f7938d9bb23a4f5687c4e6071b40cc25c8a4904fb048b9f0ff88

See more details on using hashes here.

File details

Details for the file gramps_object_query_language-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gramps_object_query_language-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58b322839c99aefdfdf5d865b37609d8a42408eab4a6e9e0925083b46eb72ddb
MD5 594434a8af0044cdb7705c76e7f9061f
BLAKE2b-256 0c26b0d6143fb2b8197f79f3e57dcfaa1ed315c1e10b9a647e4741e4d55e3fed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page