histrio/py-couchdb

I need some help using your Resource.put API

leifhanack opened this issue · 1 comments

Hi @histrio

I hope you can help me:) I struggle with putting this value: [{db_fragmentation, \"50%\"}, {view_fragmentation, \"50%\"}]into the CouchDB config -> invalid JSON.

Do you know how to write/encode \"50%\"? When I remove the \" it is valid JSON, but not a valid configuration value:

pycouchdb.resource.Resource("http://192.168.42.100:5984").put('_config/foo/bar', data="\"[{db_frag, false}]\"")

I tried some combination and played with adding params={"raw":"true"}, so fare without success:(

Do you have an idea?

Thanks a lot, Leif

I got it. json.dumps is my friend.

response = Resource(couchdb_uri).put('_config/{0}/{1}'.format(section, key), data=json.dumps(value))