[ckan-dev] Empty datastore table in CKAN
Michael Nielsen
mic.niel84 at gmail.com
Wed Feb 24 16:46:35 UTC 2016
Parsing 'filters': {} actually deletes the table, not just the rows.
On Wed, Feb 24, 2016 at 3:06 PM, Ian Ward <ian at excess.org> wrote:
> I don't think this was the question originally asked, but to remove
> all rows with datastore_delete without deleting the table you need to
> pass "filters": {} or similar. If you omit filters completely the
> table iteself will be removed. Would be great to make this clearer in
> the docs.
>
> We don't currently offer a way to delete rows with sql expressions
> like ">". You could issue that kind of update directly with SQL (if
> you have access) or iterate over all the rows to delete with separate
> datastore_delete calls.
>
> On Wed, Feb 24, 2016 at 8:13 AM, Vitor Baptista <vitor at vitorbaptista.com>
> wrote:
> > (As answered in stackoverflow)
> >
> > To delete a datastore table's contents without deleting its structure,
> you
> > simply call "datastore_delete" without passing any "filters".
> >
> > On 24 February 2016 at 12:41, Michael Nielsen <mic.niel84 at gmail.com>
> wrote:
> >>
> >> Question also asked at
> >>
> http://stackoverflow.com/questions/35598133/delete-all-records-with-id-higher-than-x-in-ckan
> .
> >>
> >> I'm trying to use the datastore_api in CKAN (ckan.org) and want to
> delete
> >> all records with an id higher than X - my goal is simply to delete ALL
> >> records without deleting the table.
> >>
> >> Docs:
> >>
> http://docs.ckan.org/en/ckan-2.5.1/maintaining/datastore.html?highlight=filter#ckanext.datastore.logic.action.datastore_delete
> >>
> >> Running the API with
> >>
> >> 'filters': {'_id': '0'}
> >>
> >> does work, but setting
> >>
> >> {'_id': '>0'}
> >>
> >> or
> >>
> >> {'_id': '*'} fails.
> >>
> >> How can I empty a table in the datastore without deleting the table?
> >>
> >> The SQL generated in CKAN is:
> >>
> >> ...9b89-7ab1c36c8e00" WHERE ("_id" = '*') ...
> >>
> >> So it make sense why it fails, but I don't know how to use the API calls
> >> with either wildcards or "higher than".
> >>
> >> _______________________________________________
> >> ckan-dev mailing list
> >> ckan-dev at lists.okfn.org
> >> https://lists.okfn.org/mailman/listinfo/ckan-dev
> >> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> >>
> >
> >
> >
> > --
> >
> > Vítor Baptista
> >
> > http://vitorbaptista.com
> >
> >
> > _______________________________________________
> > ckan-dev mailing list
> > ckan-dev at lists.okfn.org
> > https://lists.okfn.org/mailman/listinfo/ckan-dev
> > Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> >
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160224/db724755/attachment-0003.html>
More information about the ckan-dev
mailing list