healthkit-to-sqlite-cli

Crates.iohealthkit-to-sqlite-cli
lib.rshealthkit-to-sqlite-cli
version0.0.4
sourcesrc
created_at2022-12-31 05:16:02.380684
updated_at2022-12-31 07:33:30.169655
descriptionCommand-line tool to convert Apple HealthKit data to a SQLite database.
homepagehttps://github.com/jshrake/healthkit-to-sqlite
repositoryhttps://github.com/jshrake/healthkit-to-sqlite
max_upload_size
id748250
size414,286
Justin Shrake (jshrake)

documentation

https://docs.rs/healthkit-to-sqlite-cli

README

healthkit-to-sqlite

ci crates.io Apache 2.0 License: MIT

Command-line tool to convert Apple HealthKit data to a SQLite database.

workout-routes-examples

Getting Started

  1. Open the Health app on your iOS device.
  2. Click your profile icon in the top-right corner.
  3. Click the "Export All Health Data" button.
  4. Share the resulting ZIP archive to your computer.
  5. Run the healthkit-to-sqlite tool on the exported ZIP archive.
cargo install healthkit-to-sqlite-cli
healthkit-to-sqlite export.zip sqlite://healthkit.db

Datasette

You can use https://datasette.io/ to view and explore the resulting SQLite database file. Install the https://datasette.io/plugins/datasette-geojson-map plugin to visualize the workout routes data on a map.

datasette install datasette-geojson-map
datasette healthkit.db

Decisions

  • Only the Record, Workout, and ActivitySummary elements are currently exported.
  • Record elements are inserted to a table with a name matching the value of the element's type attribute.
  • Workout elements are inserted to a table named "Workout".
    • The descendent workoutEvent and workoutStatistics elements are represented as JSON columns.
    • The descendent workoutRoute element is converted to a GeoJSON LineString and stored in a JSON column named "geometry" for easy integration with https://datasette.io/plugins/datasette-geojson-map.
    • The JSON columns can be verbose and result in large HTML table cell sizes, making it difficult to browse the results. In this case, it may be useful to specify the truncate_cells_html setting datasette healthkit.db --setting truncate_cells_html 40. Note that this setting does not appear to be compatible with the datasette-pretty-json plugin.
  • ActivitySummary elements are inserted as rows to a table named "ActivitySummary".
  • In an attempt to future proof against Apple adding, removing, or changing element attributes, the code only assumes the existence of a limited number of attributes:
    • Record elements must have a type attribute.
    • Workout elements must have a workoutActivity attribute.
    • MetadataEntry elements must have key and value attributes.
    • FileReference elements must have a path attribute.
Commit count: 18

cargo fmt