[Ckan-users] CKAN DataStore problem
Pedro Ferro
pedro.ferro at gmail.com
Wed Dec 16 18:01:33 UTC 2015
Hi,
First, what's the link to see the ckan forum list?
During the installation of DataSote extension I had a problem regarding the
datastore set permissions.
Problem that Mat Witts was kind to explain and solve:
http://stackoverflow.com/questions/34271329/ckan-datastore-set-permissions/34308811#34308811
Now I had other problems on the installation of DataStore...
(I´m using the official documentation for a installation from source on
CentOS - http://docs.ckan.org/en/ckan-2.2/datastore.html
<http://docs.ckan.org/en/ckan-2.2/datastore.html#set-permissions>)
I made
paster datastore set-permissions postgres -c /etc/ckan/default
/development.ini
result was: Set permissions for read-only user: SUCCESS
After to Test the set-up
curl -X GET
http://127.0.0.1:80/api/3/action/datastore_search?resource_id=_table_metadata
<http://127.0.0.1/api/3/action/datastore_search?resource_id=_table_metadata>
result was:
{"help": "Search a DataStore resource.\n\n The datastore_search action
allows you to search data in a resource.\n DataStore resources that
belong to private CKAN resource can only be\n read by you if you have
access to the CKAN resource and send the appropriate\n
authorization.\n\n :param resource_id: id or alias of the resource to
be searched against\n :type resource_id: string\n :param filters:
matching conditions to select, e.g {\"key1\": \"a\", \"key2\": \"b\"}
(optional)\n :type filters: dictionary\n :param q: full text query
(optional)\n :type q: string\n :param plain: treat as plain text
query (optional, default: true)\n :type plain: bool\n :param
language: language of the full text query (optional, default: english)\n
:type language: string\n :param limit: maximum number of rows to return
(optional, default: 100)\n :type limit: int\n :param offset: offset
this number of rows (optional)\n :type offset: int\n :param fields:
fields to return (optional, default: all fields in original order)\n
:type fields: list or comma separated string\n :param sort: comma
separated field names with ordering\n e.g.: \"fieldname1,
fieldname2 desc\"\n :type sort: string\n\n Setting the ``plain`` flag
to false enables the entire PostgreSQL `full text search query
language`_.\n\n A listing of all available resources can be found at the
alias ``_table_metadata``.\n\n .. _full text search query language:
http://www.postgresql.org/docs/9.1/static/datatype-textsearch.html#DATATYPE-TSQUERY\n\n
If you need to download the full resource, read :ref:`dump`.\n\n
**Results:**\n\n The result of this action is a dictionary with the
following keys:\n\n :rtype: A dictionary with the following keys\n
:param fields: fields/columns and their extra metadata\n :type fields:
list of dictionaries\n :param offset: query offset value\n :type
offset: int\n :param limit: query limit value\n :type limit: int\n
:param filters: query filters\n :type filters: list of dictionaries\n
:param total: number of total matching records\n :type total: int\n
:param records: list of matching results\n :type records: list of
dictionaries\n\n ", "success": true, "result": {"resource_id":
"_table_metadata", "fields": [{"type": "text", "id": "_id"}, {"type":
"name", "id": "name"}, {"type": "oid", "id": "oid"}, {"type": "name", "id":
"alias_of"}], "records": [{"_id": "1fab8662e5772995", "alias_of":
"pg_views", "name": "_table_metadata", "oid": 21974}, {"_id":
"21b5fe766665b205", "alias_of": "pg_tables", "name": "_table_metadata",
"oid": 21974}], "_links": {"start":
"/api/3/action/datastore_search?resource_id=_table_metadata", "next":
"/api/3/action/datastore_search?offset=100&resource_id=_table_metadata"},
"total": 2}
I think that's ok, no?
Than, following the documentation, To test the whether the set-up allows
writing, you can create a new DataStore resource. To do so, run the
following command:
curl -X POST http://127.0.0.1:80/api/3/action/datastore_create -H
"Authorization: {378f0d31-ffe7-4f40-916a-d4e372fe372e}" -d '{"resource_id":
"d70df5a0-6e38-47a9-a37e-10e37b9f0852}", "fields": [ {"id": "a"}, {"id":
"b"} ], "records": [ { "a": 1, "b": "xyz"}, {"a": 2, "b": "zzz"} ]}'
result
{"help": "Adds a new table to the DataStore.\n\n The datastore_create
action allows you to post JSON data to be\n stored against a resource.
This endpoint also supports altering tables,\n aliases and indexes and
bulk insertion. This endpoint can be called multiple\n times to
initially insert more data, add fields, change the aliases or indexes\n
as well as the primary keys.\n\n To create an empty datastore resource
and a CKAN resource at the same time,\n provide ``resource`` with a
valid ``package_id`` and omit the ``resource_id``.\n\n If you want to
create a datastore resource from the content of a file,\n provide
``resource`` with a valid ``url``.\n\n See :ref:`fields` and
:ref:`records` for details on how to lay out records.\n\n :param
resource_id: resource id that the data is going to be stored against.\n
:type resource_id: string\n :param force: set to True to edit a
read-only resource\n :type force: bool (optional, default: False)\n
:param resource: resource dictionary that is passed to\n
:meth:`~ckan.logic.action.create.resource_create`.\n Use instead of
``resource_id`` (optional)\n :type resource: dictionary\n :param
aliases: names for read only aliases of the resource. (optional)\n :type
aliases: list or comma separated string\n :param fields: fields/columns
and their extra metadata. (optional)\n :type fields: list of
dictionaries\n :param records: the data, eg: [{\"dob\": \"2005\",
\"some_stuff\": [\"a\", \"b\"]}] (optional)\n :type records: list of
dictionaries\n :param primary_key: fields that represent a unique key
(optional)\n :type primary_key: list or comma separated string\n
:param indexes: indexes on table (optional)\n :type indexes: list or
comma separated string\n\n Please note that setting the ``aliases``,
``indexes`` or ``primary_key`` replaces the exising\n aliases or
constraints. Setting ``records`` appends the provided records to the
resource.\n\n **Results:**\n\n :returns: The newly created data
object.\n :rtype: dictionary\n\n See :ref:`fields` and :ref:`records`
for details on how to lay out records.\n\n ", "success": false, "error":
{"resource_id": ["Not found: Resource"], "__type": "Validation
Error"}}(default)[root at srvlgis01 ckan]#
The folder where the file that correspond to the resource have all
permissions
[image: Imagem intercalada 1]
as well the file it self:
[image: Imagem intercalada 2]
Hope that the my problem could be understand
(I am not an IT guy, so some of my doubts may seem pretty basic / strange)
thanks in advance
Pedro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-users/attachments/20151216/8044f4dc/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 4389 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-users/attachments/20151216/8044f4dc/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 3770 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-users/attachments/20151216/8044f4dc/attachment-0005.png>
More information about the ckan-users
mailing list