I have a Kobo eReader that I use for most of my reading. After finishing a recent book, I wanted to review all the highlights and annotations I had made. Kobo provides a built-in way to do this, but the device is rather slow, and the screen is small. This made it challenging to quickly review all my notes.
After conducting some research, I learned that Kobo uses an on device SQLite database under the hood. Around this time, I was also exploring DuckDB, so I thought this could be an excellent opportunity to delve deeper into DuckDB.
Locating the SQLite Database
To find the database, you will need to connect your Kobo to your computer. One mounted, you can find the database at .kobo/KoboReader.sqlite
. On my Mac, the full path is:
Reading Kobo Data into DuckDB
You can read the sqlite database directly into DuckDB. Use the -readonly
flag to ensure tha you don’t accidentally write to the database.
I learned from trial and error that the columns do not all have consistent types.
To get around this change the following sqlite setting:
DuckDB Basics
There are several functions I found to be the most useful while exploring the data.
SHOW TABLES;
- Display all tables in the database.DESCRIBE <table>;
- Display all column names and types.maxrows <n>
- Limit the number of rows displayed.
Understanding your library
I found the following tables to have the most interesting and relevant data.
content
- Has 1 row for each chapter in each book.Bookmark
- Has 1 row for each highlight/annotation.
The database has a total of 33 tables, but I did not find very much useful data in the other tables.
Query: List all books
Query: List all books and chapters
Query: List all highlights and annotations
All of your text highlights can be found in Bookmark.Text
. If you left a note within that highlight, it can be found in Bookmark.Annotation
. Using a join, you can enrich the Bookmark table with info about the book and chapter.
Exporting Data
DuckDB simplifies exporting data into various formats. After determining the appropriate query to find all highlights and annotations for the completed book, I exported the information to a CSV file. This allowed me to easily copy and paste the table into Notion for further review and note-taking.