After making any changes, you will need to close the Calendar app. When you restart it, the new calendars will be available.
For some reason, all newly added calendars are called “Personal”, but underneath it shows their description - which I’ve set to the name you chose. I suspect it’s called “Personal” due to the value of the Flags field I’ve set, but unfortunately this seems to be undocumented, so I had to use the value that someone else said to use.
Each time you run the script, it backs-up the current Calendar database to “/root/Calendar_backup.db”, although I don’t expect any problems, because it first checks the database’s structure looks right. But if you DO have any serious Calendar problems, please do NOT run the script again until you have renamed the backup file (so it doesn’t get overwritten).
= Unfortunately SfOS’s built-in terminal doesn’t handle 24-bit ANSI colour codes, so you won’t see any coloured squares in that case. But I find it easier to SSH into the phone from my PC for stuff like this, and so in that case the colours are visible.
The calendar database is a user file, no need to be root to run the script. But indeed, the database file is not readable/writable by the user, but by a “privileged” user. To do this, instead of devel-su (which give you root access on all files in your phone), issue devel-su -p instead. This will give you access to the user files, within the privileged group.
Beware that deleting a calendar after you’ve added/imported events to it seems to cause problems, so I strongly advise against this. So it’s better to just restore the backup of the database from before you added any calendars, or at least from before you added any events.
Deleting calendars that contain events should now work correctly. (Previously it deleted the calendar but not the events it contained, leading to orphaned events. Now it deletes all events associated with that calendar.)
I’ve also made my script less sensitive to changes in database structure - it should now only complain if something it needs is missing.