tarantool / tarantool-python

Python client library for Tarantool
https://www.tarantool.io
BSD 2-Clause "Simplified" License
101 stars 46 forks source link

Selecting all records doesn't work #83

Closed ErgNoor closed 7 years ago

ErgNoor commented 8 years ago

Tarantool 1.7.1-179-g1c01afd tarantool-python 0.5.4 python: 2.7.12 + 3.5.2

Can't select all records without specifying a key - raises

DatabaseError: (19, 'Invalid key part count in an exact match (expected 1, got 0)')

None of the examples from documentation work.

tnt = Connection("127.0.0.1", 3301)
tnt.select('todo') # 'todo' - space name
c.select('filters', [])

All of the above produce errors

>>> tnt.select("todo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/tarantool/connection.py", line 659, in select
    response = self._send_request(request)
  File "/usr/lib/python2.7/site-packages/tarantool/connection.py", line 283, in _send_request
    request)
  File "/usr/lib/python2.7/site-packages/tarantool/connection.py", line 207, in _send_request_wo_reconnect
    response = Response(self, self._read_response())
  File "/usr/lib/python2.7/site-packages/tarantool/response.py", line 77, in __init__
    raise DatabaseError(self._return_code, self._return_message)
tarantool.error.DatabaseError: (19, 'Invalid key part count in an exact match (expected 1, got 0)')

It looks like this issue like #76

scorday commented 8 years ago

Same here. Saw that #76 was closed, but still can't perform empty select.

amdei commented 7 years ago

In order to select all records from space do:

tnt = tarantool.connect("localhost", 3322)
sp = tnt.space('lalala') # lalala - space name
n_list = sp.select(index=0, iterator=ITERATOR_ALL)
bigbes commented 7 years ago

Everything should works fine on latest 0.5.5 tarantool config:

[± |master ↑2 ?:1 ✗|] → cat 1.lua
box.cfg{
    listen = 3310,
}

local sp = box.schema.create_space('help', {})
sp:create_index('pr', {
    type = 'hash'
})
sp:insert{1, 2, 4}
sp:insert{2, 3, 4}

box.schema.user.grant('guest', 'read,write', 'space', 'help')

python+output

In [27]: a = tarantool.connect('localhost', 3310)

In [28]: b = a.space(512)

In [29]: b.select()
Out[29]:
- [1, 2, 4]
- [2, 3, 4]

In [30]: b.select(index=0)
Out[30]:
- [1, 2, 4]
- [2, 3, 4]
bigbes commented 7 years ago

Feel free to reopen this ticket in case you still have problems with this select