[ckan-discuss] Datacatalog

Sean Hammond sean.hammond at okfn.org
Tue Jul 9 20:17:33 BST 2013


So you're trying to export all of the datasets of your CKAN site into
one big CSV file? You might find the `paster simple-dump-csv` command
does what you want:

http://docs.ckan.org/en/latest/paster.html#exporting-datasets-to-json-or-csv

If that's not exactly what you want, I'd recommend writing a simple
Python script that uses the CKAN API, rather than accessing the DB
directly:

http://docs.ckan.org/en/latest/api.html

On Mon, Jul 08, 2013 at 05:51:59PM +0200, Luca Racchetti wrote:
> Good morning,
> I would like to make a catalog of my CKAN dataset.
> To do this I started with export the database into CSV, and then I
> have created a function and a trigger on the Postgresql DB:
> 
>     CREATE FUNCTION create_datacatalog ()
>     RETURNS trigger
>     AS $create_datacatalog$
>     BEGIN EXECUTE '
>     Copy (SELECT "name" AS "nome", "description" AS "descrizione",
> "url" AS "url", "format" AS "formato", "last_modified" AS "ultima
> modifica", "author" AS "autore", "author_email" AS "email autore",
> "maintainer" AS "manutentore", "maintainer_email" AS "email
> manutentore" FROM (SELECT "name", "description", "url", "format",
> "last_modified", "resource_group_id", "package_id", resource.id AS
> "url_id" FROM "resource_group" JOIN "resource" ON
> resource_group.id=resource.resource_group_id) AS "resource" JOIN
> (SELECT "id", "author", "author_email", "maintainer",
> "maintainer_email", "name" AS "url_name" FROM "package") AS
> "package" ON resource.package_id=package.id ORDER BY "last_modified"
> DESC) To
> ''/usr/lib/ckan/default/src/ckan/ckan/public/datacatalog.csv'' With
> CSV HEADER;
>     ';
>     RETURN NEW;
>     END;
>     $create_datacatalog$
>     LANGUAGE plpgsql;
> 
>     CREATE TRIGGER datacatalog_update
>     AFTER insert OR update
>     ON resource
>     FOR EACH ROW
>     EXECUTE PROCEDURE create_datacatalog();
> 
> 
> Then I assigned permissions in writing to the output file.
> 
> 
> Now if I create a new dataset and I do point to the url <server> /
> datacatalog.csv is taken the url of datacatalog.
> But if I update one of the other dataset that file is modified and
> updated. When I download the datacatalog returns the new file, but
> the preview and the general datastore still contain the old file.
> 
> How to upgrade and automate it?
> 
> Thanks,
> Luca Racchetti
> Matricola: 703311
> Informatica, Università degli Studi di Milano-Bicocca
> 
> Senatore Accademico
> Rappresentante studenti CCD Scienze e Tecnologie Informatiche
> 
> --------------------------------------------------------------------------------
> -Internet Email Confidentiality Footer-
> La presente comunicazione, con le informazioni in essa contenute e
> ogni documento o file allegato, e' rivolta unicamente alla/e
> persona/e cui e' indirizzata ed alle altre da questa autorizzata/e a
> riceverla. Se non siete i destinatari/autorizzati siete avvisati che
> qualsiasi azione, copia, comunicazione, divulgazione o simili basate
> sul contenuto di tali informazioni e' vietata e potrebbe essere
> contro la legge (art. 616 C.P., D.Lgs n. 196/2003 Codice in materia
> di protezione dei dati personali). Se avete ricevuto questa
> comunicazione per errore, vi preghiamo di darne immediata notizia al
> mittente e di distruggere il messaggio originale e ogni file
> allegato senza farne copia alcuna o riprodurne in alcun modo il
> contenuto.
> This e-mail and its attachments are intended for the addressee(s)
> only and are confidential and/or may contain legally privileged
> information. If you have received this message by mistake or are not
> one of the addressees above, you may take no action based on it, and
> you may not copy or show it to anyone; please reply to this e-mail
> and point out the error which has occurred.



> _______________________________________________
> ckan-discuss mailing list
> ckan-discuss at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-discuss
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-discuss




More information about the ckan-discuss mailing list