Couchbase: python SDK "uppend" -


i want "uppend_multi": append_multi (http://pythonhosted.org/couchbase/api/couchbase.html#couchbase.bucket.bucket.append_multi) of keys may not exist. if not exist append operation should insert. how can this? nothing in api docs suggests supported, imagine common operation.

right doing this, seems natural of thing need highly doubt best way it:

def _uppend_multi(bucket, append_dict):     reinsert_dict = {}     try:         bucket.append_multi(append_dict, format = couchbase.fmt_utf8)      except couchbaseerror exc:         k, res in exc.all_results.items():             if res.success:                 pass             else:                 reinsert_dict[k] = append_dict[k]      if len(reinsert_dict.keys()) > 0:         bucket.insert_multi(reinsert_dict, format = couchbase.fmt_utf8) 

as far know there no such "uppend" operation in couchbase python sdk, nor in lower-level c api (libcouchbase).

what you're doing pretty reasonable solution.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -