How to export Calendar data from Sailfish OS?

Jolla Care -

This article explains how to copy the calendar items (appointments) from the SQLite database in Sailfish OS to iCalendar (ics) or CSV files. The iCalendar files can then be imported to a Calendar application on another platform. CSV files, in turn, can be viewed with apps like LibreOffice Calc or MS Excel.

The UI of Sailfish Calendar has the option for sharing appointments (in iCalendar format). Unfortunately this is available for single appointments only - the option to select all items for sharing is missing (OS version 3.1.0, and earlier).


1. Preparations

1.1.  Developer tools

  • Enable Developer Mode
  • Open Terminal app on your computer and create an SSH connection to your Sailfish device
    • SSH over USB from Windows to Sailfish: read this
    • SSH over USB from Ubuntu to Sailfish: read this.

Define a symbol for you home area. We will need it later:

cd $HOME
export MYHOME=$(pwd)


1.2.  Add SQL tool to your Sailfish OS device

devel-su   ## your SSH password is needed here
pkcon refresh
pkcon install sqlite


2. Exporting in iCalendar format

2.1.  Get your calendar (notebook) names and UIDs

This step must be traversed to dig out the names of the calendars (NOTEBOOK_UID) used in the SQL database of the Sailfish Calendar app. These names will be needed in the further steps where we collect the actual calendar events from the database.

devel-su -p sqlite3 \
$MYHOME/.local/share/system/privileged/Calendar/mkcal/db \
"SELECT Name, CalendarId FROM Calendars;"

An example of the output is shown below:

John's google|be653166-8437-4f2a-bb34-53566874c156

The first item is the default personal calendar (see Manage calendars in the pulley of Calendar app). The 3rd one is the calendar of a Google account, and the 4th one is the calendar of an Exchange account.

Each item has the NOTEBOOK_UID right after the separator character |.



2.2.  Export calendar data to an iCalendar (.ics) file

devel-su -p icalconverter export -n NOTEBOOK_UID XXXXX.ics

Replace NOTEBOOK_UID with one of the actual id's from step 2.1 and replace XXXXX.icswith a descriptive file name of your choice.

An example:

devel-su -p icalconverter \ 
export -n be653166-8437-4f2a-bb34-53566874c156 john-google.ics
Enjoy your privileges.
[D] main:88 - Successfully wrote: 2741 bytes of data to: "john-google.ics"


2.3. Collect the resulting file(s)

Move file .ics file from your Sailfish OS device to a computer or another devivce where it can be imported to a calendar application.


3. Exporting in CSV format

3.1.  Copy your calendar database to a working directory

This step was added here just to ensure that the actual database would not get accidentally damaged.

devel-su -p \
cp $MYHOME/.local/share/system/privileged/Calendar/mkcal/db $MYHOME


3.2. Give the following commands to access the SQL database

sqlite3 db

sqlite> .headers on
sqlite> .mode csv
sqlite> .output calendars.csv
sqlite> select * from Components;
sqlite> .quit


3.3. Collect the resulting file

Move file calendars.csv from your Sailfish OS device to a computer where you have LibreOffice Calc (or a corresponding spreadsheet app).  Open the CSV file with that app.

  • there should be one row for each appointment
  • columns have the data from various fields of the Calendar app
  • the text of the appointments should be readable (as much as it can be in a table format).



Have more questions? Submit a request
Powered by Zendesk