1. Data Integrations
  2. Ckan

CKAN Integration handler

This handler is used to integrate with CKAN. CKAN is Data Catalogue for Open Data, and it stores data in a DataStore. To retrieve data from CKAN, you need to use the CKAN API.

Creating a CKAN API client

Connecting to CKAN is done by creating a CKAN API client In this handler, you can create a CKAN API client with ckanapi.

*Note: Some CKAN instances will require you to provide API key. You can find it in the CKAN user panel.

from ckanapi import RemoteCKAN
ckan = RemoteCKAN('https://ckan.example.com/', apikey='YOUR_API_KEY')

CKANAPI client supports all API methods of CKAN. For our handler we are using the DataStore API

The datastore_search_sql action supports raw SQL commands to be used to search for the data

Example:

ckan.action.datastore_search_sql(sql='SELECT * FROM "resource_id"')

Usage

In order to make use of this handler and connect to a Ckan server in MindsDB, the following syntax can be used:

CREATE DATABASE ckan_datasource          --- display name for the database
WITH ENGINE = 'ckan',                    --- name of the MindsDB handler
PARAMETERS = {
  "url": " ",                            --- host name, IP address, or a URL
  "apikey": " "                          --- the API key used for authentication
};