• Stars
    star
    176
  • Rank 216,924 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Export Apple Notes to SQLite

apple-notes-to-sqlite

PyPI Changelog Tests License

Export Apple Notes to SQLite

Installation

Install this tool using pip:

pip install apple-notes-to-sqlite

Usage

For help, run:

apple-notes-to-sqlite --help

You can also use:

python -m apple_notes_to_sqlite --help

To save your notes to a SQLite database called notes.db run:

apple-notes-to-sqlite notes.db

A progress bar will be shown.

You can stop it after a specified number of notes using --stop-after:

apple-notes-to-sqlite notes.db --stop-after 10

To dump the notes to standard output out as newline-delimited JSON, rather than saving them to a database, use the --dump option:

apple-notes-to-sqlite --dump

Schema

The database schema generated by this tool looks like this:

CREATE TABLE [folders] (
   [id] INTEGER PRIMARY KEY,
   [long_id] TEXT,
   [name] TEXT,
   [parent] INTEGER,
   FOREIGN KEY([parent]) REFERENCES [folders]([id])
);
CREATE TABLE [notes] (
   [id] TEXT PRIMARY KEY,
   [created] TEXT,
   [updated] TEXT,
   [folder] INTEGER,
   [title] TEXT,
   [body] TEXT,
   FOREIGN KEY([folder]) REFERENCES [folders]([id])
);
CREATE UNIQUE INDEX [idx_folders_long_id]
    ON [folders] ([long_id]);

apple-notes-to-sqlite --help

Usage: apple-notes-to-sqlite [OPTIONS] [DB_PATH]

  Export Apple Notes to SQLite

  Example usage:

      apple-notes-to-sqlite notes.db

  This will populate notes.db with 'notes' and 'folders' tables containing all
  of your notes.

Options:
  --version             Show the version and exit.
  --stop-after INTEGER  Stop after this many notes
  --dump                Output notes to standard output
  --schema              Create database schema and exit
  --help                Show this message and exit.

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd apple-notes-to-sqlite
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest