Thank you for the script! I finally got it to compile (LIBsqlite3, not plain sqlite3). Fail... Anyway, I ran the script, and it seems to have written to the cc.db file (access time is updated), however the kindle did not read the new collections. After rebooting the kindle to make sure, I took a look into the cc.db file (both on the kindle and the unix box) and both have no entries for collections.
Is there a step I am missing? Seems that the problem is with adding the correct entries to the cc.db file in the first place...