GraFIT
Loads Garmin FIT files into a SQLite database and visualizes them in Grafana.
GraFIT parses .fit files (activities, sleep, GPS, etc.) using python-fitparse, writes them to SQLite using a schema generated from the FIT profile, and ships with Grafana provisioning (datasource + dashboards) so you can browse the data immediately.
Dashboards
Screenshots of the bundled dashboards on the demo data. Click one for the full page.
Overview |
Day Summary |
Overnight Summary |
Activity Summary |
Records |
GPS Heatmap |
Saved Locations |
Install
uv tool install grafit
Or run without installing:
uvx grafit <command> [options]
Requires Python 3.11+.
Usage
uv run grafit <command> [options]
Commands
init <db_path>— create and initialize the SQLite database.import <path> <db_path>— import a FIT file or directory of FIT files into the database.--forcereimport files already present in the database.--reimport-stalereimport only the files that would change: ones holding messages or fields the current FIT profile now decodes, ones affected by an import fix in a newer GraFIT, and ones imported before GraFIT recorded this. Everyimportreports how many such files there are, by directory.--no-recursivedo not recurse into subdirectories.--fetch-weatherlook up historical hourly weather (temperature, apparent temperature, humidity) for each session's start coordinates and date from the Open-Meteo archive. Failures are logged and skipped — the FIT import itself never fails because of weather.
backfill-weather <db_path>— fetch weather for sessions already imported without--fetch-weather. Safe to re-run: only sessions missing weather are queried; rate-limited sessions, and every session when the API can't be reached, are picked up on the next run. The archive lags a few days, so a session still missing hours after an answer is retried with a growing wait (2 h, 4 h, ... up to a week) and given up on after 10 tries.--forcere-fetch weather even for sessions that already have it, including ones given up on.--weather-limit Nrequest at most N sessions per run, those tried least first and then the newest (default 50,0for no cap).import --fetch-weathertakes it too.
stats <db_path>— show row counts per table.purge <db_path> --file-hash <sha256>— remove all rows imported from a given file. On its own the file comes back on the next import if it is still in the source tree.--excludealso keep it from being imported again.
exclude <db_path>— keep files from being imported. Exclusions are stored in the database, so they hold for every laterimport.--file-hash <sha256>one version of a file;--path GLOBa glob over the path below the import root, e.g.Monitor/*orActivity/2024-*. Both repeatable. Already imported files that match stay until purged; adding a path reports how many there are.--removedrop the given exclusions;--listshow them.
archived <db_path>— list the file versions kept in the archive: ones a newer version of the same file replaced, and older copies (a backup restored over the file) that were archived on arrival instead of rolling the newer one back. Shows each version's id, when it was imported, its latest timestamp, its row count and the live version at its path.--path GLOBonly versions whose path (below the import root, e.g.Monitor/*) matches.
restore <db_path> <import_id>— make an archived version live again. The version it replaces is archived in turn and can be restored the same way, and later imports skip the replaced version's file instead of reinstating it.generate-schema <output>— write the full DDL SQL to a file.install-provisioning <dest>— copy the bundled Grafana provisioning (datasource + dashboards) to a directory.--forceoverwrite the destination if it exists.
demo-data <dest>— generate a synthetic Garmin FIT tree (see Demo data).--daysdays of history (default 365),--end-date YYYY-MM-DDlast day (default yesterday),--seedrandom seed,--forcewrite into a non-empty directory.
demo-weather <db_path>— fillweather_hourlywith modelled Los Angeles weather for demo data, without calling Open-Meteo.
Global flag: -v / --verbose for debug logging.
Upgrading
The schema is generated from the FIT profile, so upgrading GraFIT (or its python-fitparse dependency) can add new fields. On the next import/init, missing columns are added to existing tables automatically (you'll see a Schema: added N new column(s) notice). Values a newly documented field had in already-imported rows were kept raw, so they are decoded into the new column on that run without the source file; other new columns are NULL for already-imported rows. Each imported file records what it held that couldn't be decoded, so import reports which files a profile upgrade affects; grafit import <GARMIN> <db_path> --reimport-stale re-imports just those. Files imported by a GraFIT that didn't keep that record yet count as stale, so a database's first --reimport-stale re-imports everything once.
Monitor files imported by older versions have no timestamps on the 24/7 heart rate and intraday step samples; import counts them among the stale files, and --reimport-stale fixes them.
Files that change in place
Garmin devices keep appending to Monitor and Device files after they're first synced, and rewrite state files such as Location/Lctns.fit or Coach/schedule.fit on almost every sync. A file is identified by its path exactly as it was imported, so when the content at that path changes, the next import replaces the previous import instead of adding a second copy:
- Rows from the previous version dated before anything in the new version (history that rotated off the front of the file) stay in the live tables under the new import.
- Every other row from the previous version is moved to a
_superseded_<table>table in the same database, along with its_import_logentry. Nothing is deleted, and the dashboards never read these tables. - If the new version fails to import, the previous one stays live.
- A file cut off partway (an interrupted sync) is imported as far as it decodes and logged
partial; rows the previous version has past the cut stay live. When the complete file shows up at the same path it replaces the partial import as usual.
Databases built by older versions can hold several imports of the same path. import folds them the same way before it starts and reports it (Superseded: N older import(s) replaced; ...).
Always import a tree through the same path: ./GARMIN and /garmin count as different files.
Grafana
A docker-compose.yml is provided to run Grafana with the SQLite datasource plugin and the bundled dashboards. The database lives in the grafit_db volume and the provisioning that grafit install-provisioning writes in the grafit_provisioning volume, both shared with Grafana.
Note: the bundled compose file enables anonymous admin access and disables the login form, so it publishes Grafana on
127.0.0.1only. It is intended for local use — do not expose it to a network.
Drop your FIT files into ./GARMIN and bring it up:
docker compose up
A grafit-init container installs the bundled provisioning, runs grafit init, and runs grafit import ./GARMIN against shared volumes; Grafana waits for it to finish before starting. Re-running docker compose up reuses the database — already-imported files are skipped by hash.
Grafana is then available at http://localhost:3000.
Demo data
For demo/testing purposes, GraFIT can generate a synthetic dataset for a fictional Los Angeles athlete — a year of activities, sleep, stress, body battery, HRV, SpO2, saved locations etc:
docker compose -f docker-compose.demo.yml up
That generates the FIT files into their own volume, imports them into a separate database and starts Grafana on http://localhost:3000 with everything populated. Set GRAFIT_DEMO_DAYS=90 to generate less history — a year takes a couple of minutes and about 460 MB of database, 90 days about 115 MB.
The screenshots in Dashboards are taken from this demo. To refresh them in docs/screenshots/:
tools/refresh_screenshots.sh
It generates fresh demo data in a throwaway compose project (grafit-screenshots, Grafana on port 3199), takes the screenshots and removes the project and its volumes again, so a running demo or real stack is left alone. Arguments go to tools/screenshot_dashboards.py, e.g. --only overview.
Demo route geometry © OpenStreetMap contributors (ODbL), elevations from Open-Meteo (Copernicus DEM GLO-90).
Metadata
Release files for grafit 2.7.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 |
|---|---|---|---|---|
| grafit-2.7.0.tar.gz | 107.0 kB | Without provenance | Details for grafit-2.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grafit-2.7.0-py3-none-any.whl | Python 3 | none | any | Details for grafit-2.7.0-py3-none-any.whl |
Total release size: 224.7 kB
Release files / grafit-2.7.0.tar.gz
| Download URL | grafit-2.7.0.tar.gz |
|---|---|
| Size | 107.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
980ade8f596a528c4261cce62730893ff520b325bad944ec97a40c617948333a
|
|
BLAKE2b-256 checksum How to use checksums |
aa33c72fadb3ba6637f824f5166d1c806364193f6aef50159e4a606b97f48d8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / grafit-2.7.0-py3-none-any.whl
| Download URL | grafit-2.7.0-py3-none-any.whl |
|---|---|
| Size | 117.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
18d688bb229654cde8cca36bcbd058daa83b59dbc8b24fc7aafd8c00d3d4c6bf
|
|
BLAKE2b-256 checksum How to use checksums |
7de5465decc9de7843b3b576195c6c74c9d2c4fe4f3c248e196fc8c549dbb86a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for grafit 2.7.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.