thistle-db
Orbital element database manager. Ingests TLE (Two-Line Element) and OMM (Orbit Mean-Elements Message) files into a SQL database — the canonical, full-fidelity store — and maintains organized output files (TLE by object and by date; STK-compatible OMM CSV) in the same pass.
Nothing is silently lost: records that fail validation are retained in a
queryable rejects table with a reason code, and every run is recorded in
an ingest_runs table (thistle-db status is the dashboard).
Installation
pip install thistle-db
# For MariaDB/MySQL support:
pip install thistle-db[mysql]
Or with uv:
uv add thistle-db
Quick Start
1. Scaffold configuration
thistle-db init
This creates two files:
./config.toml-- main configuration (database, ingest sources, outputs)~/.config/thistle-db.toml-- user-local database credentials
Use -c to specify a different config path:
thistle-db -c /etc/thistle-db/config.toml init
2. Configure
Edit config.toml to set your database, ingest sources, and outputs. The
generated file is fully commented — see example.config.toml for a
complete operational layout.
SQLite (default; serverless):
[database]
drivername = "sqlite"
name = "thistle-db.db"
MariaDB/MySQL:
[database]
drivername = "mysql+pymysql"
host = "localhost"
port = 3306
name = "thistle-db"
secrets_file = "/etc/thistle-db/secrets.toml"
Then add your credentials to ~/.config/thistle-db.toml:
username = "myuser"
password = "mypassword"
Credentials never live in config.toml. Resolution order (highest
priority first): THISTLE_DB_DATABASE__USERNAME/__PASSWORD env vars,
the user secrets file, the system secrets file, config values.
3. Create the database schema
thistle-db init-db
Run once per database (idempotent — safe to re-run). Commands never create
schema implicitly, so on MariaDB/PostgreSQL you can run init-db with an
admin account and give the day-to-day account only read/write privileges.
init-db --drop destroys and recreates everything (asks for confirmation
unless --yes). For bulk restores, init-db --drop --defer-indexes
creates the schema without the read-path indexes; a later plain init-db
builds them in one fast sorted pass each.
4. Ingest
thistle-db ingest # scan configured source directories
thistle-db ingest 20260327.tle gp.json # or ingest specific files
One pass does everything: validate, store, and update every configured
output. There is no separate generate step — the steady-state cron entry
is just thistle-db ingest. Outputs are optional: with no
[[output.files]] entries, ingest is store-only (useful when the
database is queried directly, e.g. as thistle's catalog fallback).
File format is auto-detected by extension:
| Extension | Format |
|---|---|
.tle, .txt, .3le |
Two-Line Element |
.json |
Space-Track OMM JSON |
.csv |
OMM CSV |
.xml |
OMM XML |
Ingestion is idempotent (duplicates are silently absorbed — the dedup key is the verbatim record text) and incremental (unchanged files are skipped without being opened). Validation is tolerant: one bad record never aborts a file, one bad file never aborts a scan.
Records that cannot be stored — unparseable text, non-finite mandatory
elements, TLE checksum mismatches, epochs beyond the configurable future
horizon, records with no NORAD ID — are retained in the rejects
table with a reason code and provenance. Future-epoch rejects are
re-admitted automatically once their epoch comes inside the horizon.
5. Outputs
Declared as [[output.files]] entries; ingest maintains all of them
incrementally, and rebuild re-derives everything from the store (first
run, disaster recovery, or after adding an entry):
- Object files (
type = "object") — all records for one satellite, epoch order. NORAD IDs render as integers (optionally zero-padded) or alpha-5; filenames are templatable (filename = "tle_{id}{ext}"). - Date files (
type = "date") — the latest record per satellite per epoch date. - Formats:
tle(verbatim two-line passthrough — never a byte thistle synthesized) oromm-csv(the 17-column CelesTrak/STK projection, orcolumns = "full"for every store column).
Operations
thistle-db status # recent runs, reject trends, stuck runs
thistle-db verify # reconcile outputs against the store (weekly cron)
thistle-db rejects # summarize rejected input by reason
thistle-db rejects --export repair/ # write payloads out for repair + re-ingest
thistle-db get-tle 25544 # all TLEs for an object (alpha-5 IDs work too)
thistle-db get-tle 20260327 # nearest TLE per object to that date's noon
thistle-db export backup.csv # full-fidelity, re-ingestable backup
- Runs are data: every
ingest/rebuildwrites aningest_runsrow with per-run counters;statusreads it back. Scans exit 0 even when individual files fail (they retry next scan); explicitly named files exit 1 on failure so cron wrappers can alert. - Single-writer:
ingestandrebuildtake an advisory lock beside the config file; a second writer exits immediately. - Backup/migration:
exportwrites a full-fidelity CSV that re-ingests into any supported dialect (init-db+ingest backup.csv— also the schema-migration path; there is deliberately no migration framework).--format tle|omm-xml|omm-kvncover legacy consumers and CCSDS OMM 2.0 interchange. Physical backups of a live server belong to the native tools. - Exit codes: 0 success; 1 runtime failure / no match; 2 invalid config or usage; 3 database not initialized.
Library use
from thistle_db import get_tles
pairs = get_tles(25544) # [(line1, line2), ...] from the configured DB
thistle (the propagation package) uses this as its catalog fallback.
Supported databases
SQLite (default — dev, small and serverless deployments), MariaDB/MySQL (operational), PostgreSQL. Dialect-specific behavior is tested against all three in CI.
License
MIT
Metadata
Release files for thistle-db 0.16.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 | Provenance | Actions |
|---|---|---|---|---|
| thistle_db-0.16.0.tar.gz | 107.9 kB | Without provenance | Details for thistle_db-0.16.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| thistle_db-0.16.0-py3-none-any.whl | Python 3 | none | any | Details for thistle_db-0.16.0-py3-none-any.whl |
Total release size: 180.9 kB
Release files / thistle_db-0.16.0.tar.gz
| Download URL | thistle_db-0.16.0.tar.gz |
|---|---|
| Size | 107.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c571d572e0d4d106aa7264b4e25f7903ac189051265614cd73a1d1f6a7a825bc
|
|
BLAKE2b-256 checksum How to use checksums |
8c0ea26ac3f35255adce6ebafa1517ae3729092e6f0372ce168c17dc56913ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / thistle_db-0.16.0-py3-none-any.whl
| Download URL | thistle_db-0.16.0-py3-none-any.whl |
|---|---|
| Size | 73.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cf851d55f4d7f0996e98f33aa964ddb3b62a7a50e6efe52abbd3bd84871c482
|
|
BLAKE2b-256 checksum How to use checksums |
a4123582c5fc6641bd95a89ac8f06e9fc837d34d0887bfac19fb26c0ead7eca6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for thistle-db 0.16.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.