View Single Post
Posts: 5 | Thanked: 6 times | Joined on Jul 2010
#2
Hi guys, just a quick update, after refreshing my knowledge of SQL, I think I've figured it out, so I'm posting my current solution in case anyone else wants to know, or can give (constructive) feedback.


To create an n-daily, n-weekly, or n-monthly repeating event

First create an event in the calendar, and make it a repeating event. Close the calendar afterwards, and open an xterm.

Code:
cd ~/.calendar
cp calendardb calendardb.old
It's important to backup your old db in case you drop an entire table, update all records by mistake, or have tourettes and change everything to expletives.

Code:
sqlite3 calendardb
select * from components where summary="Exact event title";
First you need to find the id of the event you created in the calendar, using the exact event title. When you find it (returns a record instead of doing nothing), take note of the first field, eg "123".

Code:
select * from recursive where id=123;
Verify SQLite returns an entry. If it doesn't, then you haven't set the event to repeat, or used the wrong id. You could insert a record into the table manually, but it's a little more complex.

Code:
update recursive
set rrule="FREQ=WEEKLY;INTERVAL=2!",
rtype=6
where id=610;
You are now modifying the `recursive' table with a `complex' event, so incredibly complex you could probably figure it out by yourself. In this example, setting rrule to "FREQ=WEEKLY;INTERVAL=2!" means it repeats 2-weekly. DAILY, MONTHLY, YEARLY will do the same thing.
If you want an event to repeat fortnightly until a specific date, you can insert an "UNTIL=yyyymmddThhmmss", eg "UNTIL=20100101T140000", or more easily set the repeat detail in the calendar program, then copy that detail in SQLite. To be honest I'm not sure what the other details I've seen are (eg "WKST" and "BYDAY").
The `rtype' appears to be the 'repeat type', although I'm not sure why it can't deduce that from the rrule field. 1 is daily, 2 is every workday, 3 is weekly, 4 is monthly, 5 is yearly. By setting it to 6, you flag it as non-standard, and the calendar will say "Complex event. Unable to edit.". If you don't set it to >5, the calendar application will say the event is daily/weekly/monthly (but display as fortnightly/whatever), and editing any part of the event will revert back to standard behavior. By setting rtype to 6, you can modify any other detail of the event without affecting the repeat. In fact, the calendar will warn you "You are changing a repeat rule for event xxxx that is unable to be fully edited. Any exception rules will be lost. Continue?".
The final `where id=123;' means you want to update one record, not the entire table. Don't put a semicolon before this line, else you could update the entire recursive table as `complex events'. That's why we made a backup.

If it was successful, it should output nothing. Ctrl+D to close SQLite, and verify changes in the calendar.