2

I'm trying to get into the new N1QL Queries for Couchbase in Python. I got my database set up in Couchbase 4.0.0.

My initial try was to retreive all documents like this:

from couchbase.bucket import Bucket

bucket = Bucket('couchbase://localhost/dafault')

rv = bucket.n1ql_query('CREATE PRIMARY INDEX ON default').execute()
for row in bucket.n1ql_query('SELECT * FROM default'):
    print row

But this produces a OperationNotSupportedError:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2357, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1777, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Users/my_user/python_tests/test_n1ql.py", line 9, in <module>
    rv = bucket.n1ql_query('CREATE PRIMARY INDEX ON default').execute()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchbase/n1ql.py", line 215, in execute
    for _ in self:
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchbase/n1ql.py", line 235, in __iter__
    self._start()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchbase/n1ql.py", line 180, in _start
    self._mres = self._parent._n1ql_query(self._params.encoded)
couchbase.exceptions.NotSupportedError: <RC=0x13[Operation not supported], Couldn't schedule n1ql query, C Source=(src/n1ql.c,82)>

Here the version numbers of everything I use:

Couchbase Server: 4.0.0
couchbase python library: 2.0.2
cbc: 2.5.1
python: 2.7.8
gcc: 4.2.1

Anyone an idea what might have went wrong here? I could not find any solution to this problem up to now.

There was another ticket for node.js where the same issue happened. There was a proposal to enable n1ql for the specific bucket first. Is this also needed in python?

4

2 回答 2

1

您似乎没有使用QueryorIndex服务配置任何集群节点。因此,返回的错误表明没有可用的节点。

于 2015-06-18T15:13:49.870 回答
0

我在尝试创建主索引时也遇到了类似的错误。

    Create a primary index...
Traceback (most recent call last):
  File "post-upgrade-test.py", line 45, in <module>
    mgr.n1ql_index_create_primary(ignore_exists=True)
  File "/usr/local/lib/python2.7/dist-packages/couchbase/bucketmanager.py", line 428, in n1ql_index_create_primary
    '', defer=defer, primary=True, ignore_exists=ignore_exists)
  File "/usr/local/lib/python2.7/dist-packages/couchbase/bucketmanager.py", line 412, in n1ql_index_create
    return IxmgmtRequest(self._cb, 'create', info, **options).execute()
  File "/usr/local/lib/python2.7/dist-packages/couchbase/_ixmgmt.py", line 160, in execute
    return [x for x in self]
  File "/usr/local/lib/python2.7/dist-packages/couchbase/_ixmgmt.py", line 144, in __iter__
    self._start()
  File "/usr/local/lib/python2.7/dist-packages/couchbase/_ixmgmt.py", line 132, in _start
    self._cmd, index_to_rawjson(self._index), **self._options)
couchbase.exceptions.NotSupportedError: <RC=0x13[Operation not supported], Couldn't schedule ixmgmt operation, C Source=(src/ixmgmt.c,98)>

向集群添加查询和索引节点解决了这个问题。

于 2018-08-21T05:57:01.943 回答