gramps-sql-extensions
A collection of SQL-accelerated implementations of operations Gramps normally performs by walking Python objects. Each module targets one such operation. So far:
- Relationship lookup (
gramps_sql_extensions.relationship)
Relationship lookup
Gramps' own RelationshipCalculator finds the relationship between two
people by recursively walking Person/Family objects and enumerating
every distinct path to a common ancestor, not just the shortest one. Under
pedigree collapse (shared distant ancestors, or a search that reaches past
a tree's actual recorded depth), a normal genealogical pattern, that
becomes exponential: a pair connected through a handful of real ancestors
can take minutes and pin a CPU core, regardless of how big the tree is
overall.
RelationshipGraph in gramps_sql_extensions.relationship replaces the
search (not the wording) with:
- Parent/child edges pulled directly from
family.json_data'schild_ref_listvia each backend's native JSON functions (jsonb_array_elementson Postgres,json_eachon SQLite), noPerson/Familyobject construction at all. - A plain breadth-first search over that edge set, each node visited once, so cost tracks distinct people, never distinct paths to them.
- Gramps' own, unmodified, locale-aware string formatting for the actual wording.
Privacy filtering (mirroring PrivateProxyDb's rules: a private person, a
private family, or a private ChildRef are all invisible) is a live SQL
predicate, not a second precomputed copy of the graph.
Usage
This module has no idea what your database connection is. It needs
exactly one thing from you: an execute callable.
from gramps_sql_extensions import RelationshipGraph
def execute(sql: str, params: list) -> list[tuple]:
cursor = my_connection.cursor()
cursor.execute(sql, params)
try:
return cursor.fetchall()
except Exception:
return [] # DDL statements (CREATE/DROP/CREATE INDEX) have no rows
graph = RelationshipGraph(execute, dialect="sqlite") # or "postgresql"
rel_str, dist_a, dist_b = graph.relationship(handle1, handle2)
all_rels = graph.all_relationships(handle1, handle2)
execute is called many times per call to relationship()/
all_relationships(), not once, so it should be a thin, stable wrapper
around an already-open connection, not something that opens a fresh one
each time. See RelationshipGraph.__init__'s docstring for the full
contract, including treeid (for a multi-tenant Postgres schema; None
for one-tree-per-file SQLite).
License
AGPL-3.0-or-later, matching Gramps.
Metadata
Release files for gramps-sql-extensions 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gramps_sql_extensions-0.1.0.tar.gz | 14.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gramps_sql_extensions-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.1 kB
Release files / gramps_sql_extensions-0.1.0.tar.gz
| Download URL | gramps_sql_extensions-0.1.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa92961d6e5e49184f2d9d833723461bdc46b92185e67c1b56bbc13f716d98ab
|
|
BLAKE2b-256 checksum How to use checksums |
26e02a22de83e1397e9fccc483c213efc5e22516aea9cc57b2e134c74088384c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Release files / gramps_sql_extensions-0.1.0-py3-none-any.whl
| Download URL | gramps_sql_extensions-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3e7a37b4e50520f3994243bd35fa2bae55cfae5df3bac191b046003bd93a053
|
|
BLAKE2b-256 checksum How to use checksums |
23dccb38cc458faa6db6c3e2ebbcbeb2a0a02b2d6002d6b572214a010d009c3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|