Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Writing spatial views with Python

3 replies [Last post]
  • Login or register to post comments
Fri, 01/04/2013 - 17:12
BruceH
Offline
Joined: 01/04/2013
Groups: None

Hi

I can load spatial data from ArcGIS with Python and create views using the console, but I can't find sample code on writing design documents to Couchbase with Python. Anyone have some code they can share? Thanks.

Top
  • Login or register to post comments
Mon, 01/07/2013 - 10:04
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello,

I am not a Python expert so I will just point you to some sample code of give you ideas.

It looks like this library supports create/edit design documents:
- https://github.com/couchbase/couchbase-python-client

using something like:

design_doc = {"views":
              {"all_by_types":
               {"map":
                '''function (doc, meta) {
                     emit([meta.type, doc.type, meta.id], doc.value);
                     // row output: ['json', 'item', 'key4'], 'json test'
                   }'''
                },
               },
              }
# save a design document
newbucket['_design/testing'] = design_doc

Also keep in mind that the creation of view is something that could be done using REST API calls, that you can do in your script.
You can find information about REST API here: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-desig...

Regards

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Mon, 01/07/2013 - 13:49
BruceH
Offline
Joined: 01/04/2013
Groups: None

Hi

Thanks, I can write a doc into a bucket with that approach, but attempting to display the doc returns:

Error: notfound (Document does not exist)

Also, no view is created, just the doc entry, which appears broken.

I'll try via REST.

Regards

Top
  • Login or register to post comments
Mon, 01/07/2013 - 14:30
BruceH
Offline
Joined: 01/04/2013
Groups: None

Breaking news: I must have a syntax issue, I can create a simpler view with the approach, I'll chase down the issue.

Thanks again

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker