[ckan-dev] datastore_upsert error

Isabel Ruiz isaruizmellado at gmail.com
Tue May 31 09:36:24 UTC 2016


Hi all,

I have this problem using datastore API.

I create a datastore and insert rows using this code (I execute this once):

malaga = ckanapi.RemoteCKAN(URL,
    apikey=APIKEY,
    user_agent='ckanapismassa/1.0')

  malaga.action.datastore_create(
    resource_id=RESOURCE_ID,
    force=True,
    primary_key='poiIDSec'
    records=rows
  )

It works, I mean: it creates a datastore and inserts every rows.

Then, I execute a cron every minutes, that will update rows, this is the
code:

malaga = ckanapi.RemoteCKAN(URL,
    apikey=APIKEY,
    user_agent='ckanapismassa/1.0')

  malaga.action.datastore_upsert(
    resource_id=RESOURCE_ID,
    force=True,
    records=rows
  )

This returns me this error:

Traceback (most recent call last):
ValidationError: None - {u'table': [u'table does not have a unique key
defined'], u'__type': u'Validation Error'}


['Traceback (most recent call last):\n', '  File "<stdin>", line 93, in
<module>\n', '  File
"/home/ckan/ckan/lib/default/src/ckanapi/ckanapi/common.py", line 51, in
action\n    return self._ckan.call_action(name, data_dict=kwargs)\n', '
 File "/home/ckan/ckan/lib/default/src/ckanapi/ckanapi/remoteckan.py", line
83, in call_action\n    return reverse_apicontroller_action(url, status,
response)\n', '  File
"/home/ckan/ckan/lib/default/src/ckanapi/ckanapi/common.py", line 124, in
reverse_apicontroller_action\n    raise ValidationError(err)\n',
"ValidationError: None - {u'table': [u'table does not have a unique key
defined'], u'__type': u'Validation Error'}\n"]


How can I solve this ?

Is there another way to update datastore rows?


Thanks!!!

-- 
Isabel M. Ruiz Mellado
http://about.me/isabelruiz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160531/d5d54433/attachment-0002.html>


More information about the ckan-dev mailing list