Skip to content
tmills80Public

About

Read-only access to RootsMagic (.rmtree) SQLite databases. rm-find and rm-dump CLIs. Standard library only.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

rmread

Read-only access to RootsMagic (.rmtree) SQLite databases, with a couple of CLI tools for the common queries. Designed for actual research use: cite-first, provenance over polish, no third-party dependencies.

What it is

rmread is a Python library plus two CLI commands that read from RootsMagic 7+ databases (verified against RM 11.0) without modifying them. It uses only the Python standard library — sqlite3, dataclasses, argparse.

  • Read-only — always opens with mode=ro plus PRAGMA query_only. A stray write raises rather than mutating research data.
  • Standard library only — no requirements.txt, no install dance beyond pip install -e .
  • Evidence-grade — output carries source citations, never just “person @pid7 was born in FFakePlace-1”.

For the project’s sourcing rules and what “evidence-grade” means in practice, see AGENTS.md and references/evidence-discipline.md.

What it is not

  • Not a Root-aware editor. rmread will not change anything in your .rmtree, ever.
  • Not a genealogical-format converter. GEDCOM / Gramps interop belongs in a sibling tool, not this one.
  • Not built for parallel scanning. One SQLite connection per process is fine for real-world trees (100k+ persons run in a second or two); for genuinely big data, look elsewhere.

Install

git clone https://github.com/tmills80/rmread.git
cd rmread
python -m venv .venv
source .venv/bin/activate
pip install -e ".[test]"

(test pulls in pytest. The library itself has no third-party runtime dependencies.)

rmread is not published to PyPI yet. It is the dependency of rm2gramps, which lives in a sibling repository and resolves it from a checkout next door:

uv sync --all-extras

Quick start

rm-find Tree.rmtree AAAAAA           # surname search
rm-dump Tree.rmtree 1                # full person record

Both commands print to stdout and metadata to stderr. Pipe at will:

rm-find Tree.rmtree AAAAAA --format json --limit 10 | jq '.results[].primary_name.surname'
rm-dump Tree.rmtree 7 --format json > person-7.json

CLI tools

rm-find — search by surname

rm-find Tree.rmtree AAAAAA           # substring (default)
rm-find Tree.rmtree 'AAA%'           # wildcard (LIKE)
rm-find Tree.rmtree AAAAAA --exact   # literal match, no % wrap
rm-find Tree.rmtree 'AAA%' --given Frida

Both surname and --given are SQL LIKE patterns, case-insensitive:

PatternMatches
AAAAAAthe literal substring AAAAAA (auto-wrapped as %AAAAAA% when no wildcards present)
'AAA%'names starting with AAA (AAABBB, AAAAAA, AAAxxx, …)
'A_AAA'AAAAAA, ABAAAA, ACAAAA, A0AAAA, … (_ = exactly one char)
'%AAAA%'names containing AAAA anywhere

Pass --exact when you want exactly the value you typed — useful when the surname genuinely contains % or _ as literal characters.

Output formats

  • text (default) — fixed-column table, one row per person. Designed for reading; truncates long fields with ….
  • json — envelope-stamped JSON suitable for piping or scripted downstream use.
{
  "envelope": {
    "tool": "rmread",
    "schema_version": 1,
    "source_database": "Tree.rmtree",
    "db_version": 11000,
    "count": 1
  },
  "results": [
    {
      "person_id": 5,
      "unique_id": "...",
      "sex": 1,
      "living": false,
      "is_private": false,
      "primary_name": { "surname": "...", "given": "...", "...": "..." }
    }
  ]
}

The source_database and db_version stamps let a downstream tool verify provenance without trusting the caller.

The schema_version stamp says which shape the payload under the envelope has. rm-find and rm-dump emit different shapes, so they carry different versions (rmread.format.FIND_SCHEMA_VERSION and rmread.format.DUMP_SCHEMA_VERSION, both currently 1). A consumer that does not recognise the version must refuse the payload rather than guess at it.

rm-dump — full person record

rm-dump Tree.rmtree 7                       # everything
rm-dump Tree.rmtree 7 --format json          # as JSON
rm-dump Tree.rmtree 7 --no-events           # identity + family only
rm-dump Tree.rmtree 7 --no-family           # identity + events only

Dumps everything rmread knows about a single PersonID: identity, recorded life events (birth / death / burial / christening / baptism / cremation / occupation / census / probate / will / residence by default), parents, spouses, children.

--format json emits the same envelope, stamped with rmread.format.DUMP_SCHEMA_VERSION:

{
  "envelope": {
    "tool": "rmread",
    "schema_version": 1,
    "source_database": "Tree.rmtree",
    "db_version": 11000,
    "person_id": 7
  },
  "result": {
    "person": { "...": "..." },
    "events": [ { "...": "..." } ],
    "parents": [ { "...": "..." } ],
    "spouses": [ { "...": "..." } ],
    "children": [ { "...": "..." } ]
  }
}

rmcite consumes this shape. The contract is guarded by the rmcite package’s tests/test_contract.py, which asserts that rmcite’s pinned SUPPORTED_SCHEMA_VERSION still equals rmread.format.DUMP_SCHEMA_VERSION.

Exit codes

CodeMeaning
0Found and rendered
1No such PersonID in this database
2File missing or not a valid RootsMagic SQLite file

Exit codes are stable — script away.

As a library

from rmread import open_database, find_by_surname, dump_person

with open_database("Tree.rmtree") as db:
    print(f"RM version: {db.version}")

    # Library queries always go through db.con, the underlying
    # read-only sqlite3.Connection. Direct SQL is fine; the rest of
    # the package is just convenience around it.
    people = find_by_surname(db.con, "AAAAAA")
    for p in people:
        print(p.person_id, p.display_name)

    # Full person record — identity + events + parents/spouses/children.
    dump = dump_person(db.con, people[0].person_id)
    for ev in dump.events:
        print(f"  {ev.event_type_name}: {ev.date} at {ev.place}")

The public dataclass surface:

  • Name, Person, PersonDump — people
  • Event, DEFAULT_EVENT_TYPES — life facts
  • ParentRef, SpouseLink, ChildRef — family links

All dataclasses are frozen and hashable so they can go in sets or be keys.

Caveats

  • Never commit a *.rmtree file.* .gitignore at the repo root excludes *.rmtree and *.rmgc. Real RootsMagic databases contain living-people records and are not version-controlled here.
  • Use synthetic data in tests. The test suite in this repo does not open a real .rmtree. If you fork or copy the library, preserve that.
  • Cross-vault matches are not kinship. Like any RootsMagic query, same-surname hits in different researcher vaults ≠ same family. See references/evidence-discipline.md §3.

See also

  • docs/rm11-schema.md — RM 11.0 SQLite schema reference. Full column lists for every .rmtree table, verified event-type IDs, the RMNOCASE collation footgun, link-table OwnerType conventions, and the bug list verified against SampleTree.rmtree.
  • docs/scaffolding-context.md — project-local guidance (synthetic-data rules, parents-vs-co-parents, read-only safeguards).
  • references/evidence-discipline.md — the sourcing rules.

Licence

MIT. See LICENSE.

About

Read-only access to RootsMagic (.rmtree) SQLite databases. rm-find and rm-dump CLIs. Standard library only.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages