Skip to content

Instantly share code, notes, and snippets.

@eeeschwartz
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eeeschwartz/b3b0cb7769bcee479eca to your computer and use it in GitHub Desktop.
Save eeeschwartz/b3b0cb7769bcee479eca to your computer and use it in GitHub Desktop.
Configure datastore entry for code-enforcement CKAN resource
CKAN_BASE_URL=http://www.civicdata.com
CKAN_API_KEY=from-ckan-users-profile-page
resource_id='2691aff1-e555-48d3-9188-aebf1fa8323e'
fields='[{"id":"ID","type":"integer"},{"id":"Date","type":"date"},{"id":"Address","type":"text"},{"id":"Suite","type":"text"},{"id":"PermitType","type":"text"},{"id":"ConstructionCost","type":"integer"},{"id":"OwnerName","type":"text"},{"id":"Contractor","type":"text"},{"id":"parcelId","type":"text"},{"id":"lat","type":"float"},{"id":"lng","type":"float"}]'
curl -v $CKAN_BASE_URL/api/3/action/datastore_create \
-d '{"resource_id": "'$resource_id'", "fields": '$fields', "primary_key":"ID", "force":"true"}' \
-H "Authorization: $CKAN_API_KEY"
# for http://www.civicdata.com/en/dataset/lexington-code-enforcement-complaints/resource/ad346da7-ce88-4c77-a0e1-10ff09bb0622
CKAN_BASE_URL=http://www.civicdata.com
CKAN_API_KEY=from-ckan-users-profile-page
resource_id='ad346da7-ce88-4c77-a0e1-10ff09bb0622'
fields='[{"id":"CaseNo","type":"text"},{"id":"CaseYr","type":"text"},{"id":"Address","type":"text"},{"id":"DateOpened","type":"date"},{"id":"CaseType","type":"text"},{"id":"Status","type":"text"},{"id":"StatusDate","type":"date"},{"id":"Closed","type":"bool"},{"id":"parcelId","type":"text"},{"id":"lat","type":"float"},{"id":"lng","type":"float"}]'
curl -v $CKAN_BASE_URL/api/action/datastore_create \
-d '{"resource_id": "'$resource_id'","fields": '$fields', "primary_key":"CaseNo", "force":"true"}' \
-H "Authorization: $CKAN_API_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment