jshrake / healthkit-to-sqlite

Command-line tool to convert Apple HealthKit data to a SQLite database.
Apache License 2.0
8 stars 1 forks source link

error returned from database: (code: 1) near "Press": syntax error #1

Closed tomjakubowski closed 1 year ago

tomjakubowski commented 1 year ago

Ran this on my exported ZIP and got:

$ healthkit-to-sqlite export.zip sqlite://healthkit.db
Error: error returned from database: (code: 1) near "Press": syntax error

Caused by:
    (code: 1) near "Press": syntax error
jshrake commented 1 year ago

Can you run with RUST_LOG=debug and share the failing SQL query?

tomjakubowski commented 1 year ago
[2022-12-31T06:54:50Z INFO  sqlx::query] INSERT INTO HKQuantityTypeIdentifierActiveEnergyBurned (type, …; rows affected: 0, rows returned: 0, elapsed: 33.041µs

    INSERT INTO
      HKQuantityTypeIdentifierActiveEnergyBurned (
        type,
        sourceName,
        sourceVersion,
        unit,
        creationDate,
        startDate,
        endDate,
        value,
        metadata_Bench Press,
        metadata_HKMetadataKeySyncVersion,
        metadata_Barbell Row,
        metadata_HKMetadataKeySyncIdentifier,
        metadata_Squat
      )
    VALUES
      (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

Error: error returned from database: (code: 1) near "Press": syntax error

Caused by:
    (code: 1) near "Press": syntax error

Looks like the exercise name has a space in it, and that goes into a column name. I think the column name can be quoted with ""