Skip to main content

API Reference

The database

One DuckDB file, content-addressed by SHA-256, with every kernel location and tracked metakernel.

KernelDB

Content-addressed SPICE kernel database.

RegistryRow

One tracked metakernel, as a row of the metakernel registry.

KernelDB Methods

Methods for the KernelDB class

KernelDB.release()

Close the DB connection to release the lock.

KernelDB.reacquire()

Reopen the DB connection after release().

KernelDB.kernel_roots

The configured kernel roots, as expanded, resolved paths.

KernelDB.root_for()

The kernel root a download belongs in (decided 2026-11-21).

KernelDB.add_mission()

Register a mission in the database.

KernelDB.list_missions()

List all configured missions.

KernelDB.remove_mission()

Remove a mission from the database.

KernelDB.get_mission()

Look up a mission by name.

KernelDB.register_file()

Register a single kernel file and return its SHA-256.

KernelDB.aliases()

Follow the deduplication trail for a kernel.

KernelDB.alias_counts()

Map each SHA-256 to how many filenames it is known under.

KernelDB.alias_counts_by_name()

For each filename, count how many other names its content is known under.

KernelDB.scan_directory()

Recursively scan a directory tree and register all kernel files.

KernelDB.scan_roots()

Run scan_directory over every configured kernel root.

KernelDB.find_by_filename()

Find all locations for a kernel by filename.

KernelDB.find_by_hash()

Find all locations for a kernel by its SHA-256 hash.

KernelDB.resolve_kernel()

Resolve a kernel filename to an absolute path on disk.

KernelDB.report_duplicates()

Find and report kernels that exist in multiple locations.

KernelDB.index_metakernel()

Parse a metakernel and store its entries in the metakernel_entries table.

KernelDB.registry_rows()

Every tracked metakernel, ordered by mission and filename.

KernelDB.registry_row()

The registry row ref names, or None when no row matches.

KernelDB.resolve_metakernel()

The on-disk path of the metakernel ref names (#45).

KernelDB.verify_against_server()

Compare each local kernel of a metakernel against the server.

KernelDB.check_metakernel()

Check which kernels from a metakernel are already available locally.

KernelDB.check_report()

Everything the check command reports, as data (#46).

KernelDB.newer_remote_version()

A notice when the server lists a newer copy of the metakernel, else None.

KernelDB.rewrite_metakernel()

Rewrite a metakernel for local use with minimal edits.

KernelDB.verify_metakernel()

Deeply cross-check a metakernel against the database.

KernelDB.get_metakernel()

Fetch a remote metakernel, show its status, and download the missing kernels.

KernelDB.update_metakernel()

Re-fetch a metakernel from its source URL and download new or missing kernels.

KernelDB.update_all()

Re-fetch every tracked metakernel from its source, as skd update does (#47).

KernelDB.import_metakernel()

Track a metakernel that is already on disk, without a download (#47).

KernelDB.list_metakernels()

List all tracked metakernels, optionally filtered by mission.

KernelDB.metakernels_covering()

Tracked metakernels whose SPK kernels cover a body.

KernelDB.info_metakernel()

Show detailed information about a tracked metakernel, as skd show does (#47).

KernelDB.remove_metakernel()

Remove a metakernel from the registry and its entries.

KernelDB.browse_remote_metakernels()

Scan a remote NAIF mk/ directory and show the available metakernels.

KernelDB.poisoned_superseded()

Find kernels flagged as superseded by content that exists in no live location.

KernelDB.stale_locations()

List the registered locations whose file is gone from disk.

KernelDB.doctor()

Report the health of the database, with no metakernel argument (#46).

KernelDB.stats()

Print and return summary statistics.

KernelDB.deduplicate_plan()

Generate a deduplication plan without executing it.

KernelDB.deduplicate_with_symlinks()

Replace duplicate files with symlinks to the canonical copy.

KernelDB.prune()

Remove stale locations where the file no longer exists on disk.

KernelDB.prune_orphan_symlinks()

Find symlinks under the download trees whose target no longer exists.

KernelDB.prune_metakernels()

Find registry rows whose remote URL is permanently gone and optionally remove them.

KernelDB.coverage_metakernel()

Check body coverage for all SPK kernels in a metakernel.

KernelDB.store_coverage()

Upsert coverage intervals into kernel_coverage table.

KernelDB.query_coverage()

Query kernels that cover a body, optionally within a time range.

KernelDB.close()

Close the database connection.

KernelDB.__enter__()
KernelDB.__exit__()

One call against the configured database

Each opens the database named in the config, does one thing and closes it.

check()

skd check as data: the verdicts and their evidence.

get()

skd get: fetch a metakernel by URL, or re-fetch a tracked one by name.

metakernels_covering()

Tracked metakernels whose SPK kernels cover a body (at et, if given).

register_metakernel()

Track a metakernel already on disk, as skd import does.

resolve_metakernel()

The on-disk path of a tracked metakernel, from any form of reference.

scan()

Index the kernel files under directory, or under every configured root.

Configuration

The config file and the kernel roots. Nothing here prints or prompts.

Config

User configuration for spice-kernel-db.

ConfigError

The config file is corrupt, or there is none and nothing says what to write.

ensure_config()

Load the config, or write a first one around seed_root.

kernel_roots()

The configured kernel roots as expanded, resolved paths (#48).

add_root()

Append directory to the kernel roots and save (#48).

remove_root()

Remove directory from the kernel roots and save (#48).

Metakernel files

Reading and writing .tm files.

parse_metakernel()

Parse a SPICE metakernel (.tm) file from a local path, without needing a database.

parse_metakernel_text()

Parse a SPICE metakernel from text content.

Exceptions

AmbiguousKernelRoot

Nothing says which configured kernel root a download belongs in.

AmbiguousMetakernel

A metakernel reference matched several registry rows.

ConcurrentModificationError

Another process modified the kernel records during a download.

LegacyDatabaseFound

A database sits at the pre-0.19 default and nothing says to use it.

MetakernelNotTracked

A metakernel reference matched nothing that skd tracks.

MetakernelUnreachableError

The remote copy of a tracked metakernel is gone.

Hosting the CLI

spice_kernel_db.cli.app is the Typer app a host mounts under its own command (planetarypy’s plp spice); these two complete the host contract.

cli.exit_code()

The exit code for one of this package’s exceptions, or None for any other.

cli.logging_to_stderr()

For one CLI run, print the library’s warnings as bare lines on stderr.