Just wondering...
Do you have (command line or SQL) scripts to perform simple tasks with the DAViCal server? For example get a list of all appointments that match a specific topic? Or a list of all email addresses in the contacts database?
Take a look at RFC 4791 and 6352. calendar-query and addressbook-query reports should work.
-- Kenneth Murchison Principal Systems Software Engineer Carnegie Mellon University
On Apr 29, 2017, at 8:37 AM, Johan Vromans jvromans@squirrel.nl wrote:
Just wondering...
Do you have (command line or SQL) scripts to perform simple tasks with the DAViCal server? For example get a list of all appointments that match a specific topic? Or a list of all email addresses in the contacts database?
On Sat, 29 Apr 2017 18:10:15 -0400, Ken Murchison murch@andrew.cmu.edu wrote:
Take a look at RFC 4791 and 6352. calendar-query and addressbook-query reports should work.
Sure.
Just wondering if anyone had ready to use scripts.
Do you have (command line or SQL) scripts to perform simple tasks with the DAViCal server? For example get a list of all appointments that match a specific topic? Or a list of all email addresses in the contacts database?
-- Johan
On Sun, Apr 30, 2017 at 01:41:42PM +0200, Johan Vromans wrote:
On Sat, 29 Apr 2017 18:10:15 -0400, Ken Murchison murch@andrew.cmu.edu wrote:
Take a look at RFC 4791 and 6352. calendar-query and addressbook-query reports should work.
Sure.
Just wondering if anyone had ready to use scripts.
FWIW I have a bunch of scripts that can do command-line caldav/carddav querying written in Python on https://github.com/jelmer/dystros
These scripts are fairly specific to my use cases, so unlikely to be useful for you without poking around in the Python code a bit.
If you're okay copying the data over locally before querying, another option is to use a combination of vdirsyncer (https://github.com/pimutils/vdirsyncer) and e.g. khal/khard (https://github.com/pimutils/khal)
Jelmer
Hi Johan,
it's not easy because you need to process the VCALENDAR/VCARD attributes and then perform a search in the processed data (which often needs to unescape and several other things).
Here is an example to extract the SUMMARY attribute text value from VCALENDAR (including unescaping, etc.), and then compare the extracted attribute value with any value you are looking for:
SELECT dav_name, caldav_data FROM (SELECT *, regexp_replace(regexp_replace((regexp_matches(regexp_replace(caldav_data, '\r\n[\t ]', '', 'g'), '\r\nSUMMARY:(.*)\r\n', 'n'))[1], '\n', E'\n', 'g'), '\([,;\])', '\1', 'g') AS caldav_attr FROM caldav_data) AS _ WHERE caldav_attr LIKE '%abcdefghijklmnopqrstuvwxyz%';
in short: regexp_replace(XXX, '\r\n[\t ]', '', 'g') => remove line folding from VCALENDAR/VCARD (regexp_matches(XXX, , '\r\nSUMMARY:(.*)\r\n', 'n'))[1] => find the SUMMARY attribute and extract the attribute value regexp_replace(XXX, , '\n', E'\n', 'g') => replace the \n string with real newline (newline is not allowed because it is used in the VCALENDAR/VCARD format itself) regexp_replace(XXX, , '\([,;\])', '\1', 'g') => unescape the , ; and \ characters (these are escaped in text values)
the result is the whole caldav_data table with one additional column (caldav_attr) which contains the real (raw) text value from the SUMMARY attribute.
Then the outer select allows you to select all data (from the extended caldav_data table) which met your condition (in my case all object where the SUMMARY contains "abcdefghijklmnopqrstuvwxyz").
This solution is not optimal, but it does exactly what you asked :-) ... for other attributes you need to modify the "(regexp_matches(XXX, , '\r\nSUMMARY:(.*)\r\n', 'n'))[1]" part ...
JM
On 29 Apr 2017, at 14:37, Johan Vromans jvromans@squirrel.nl wrote:
Just wondering...
Do you have (command line or SQL) scripts to perform simple tasks with the DAViCal server? For example get a list of all appointments that match a specific topic? Or a list of all email addresses in the contacts database?