Quick start¶
Connecting to the server¶
Create connection to the server:
>>> import tarantool
>>> server = tarantool.connect("localhost", 33013)
Creating a space instance¶
Instance of Space
is a named object to access
the key space.
Create `` demo `` object which will be used to access the space `` 0 ``
>>> demo = server.space(0)
All subsequent operations with space 0
performed using methods of the demo
.
Data Manipulation¶
Select¶
Select one single record with id 'AAAA'
from the space demo
using primary key (index zero):
>>> demo.select('AAAA')
Select several records using primary index:
>>> demo.select(['AAAA', 'BBBB', 'CCCC'])
[('AAAA', 'Alpha'), ('BBBB', 'Bravo'), ('CCCC', 'Charlie')]
Insert¶
Insert tuple ('DDDD', 'Delta')
into the space demo
:
>>> demo.insert(('DDDD', 'Delta'))
The first element is the primary key for the tuple.
Call server-side functions¶
To call stored function method
Connection.call()
can be used:
>>> server.call("box.select_range", (0, 0, 2, 'AAAA'))
[('AAAA', 'Alpha'), ('BBBB', 'Bravo')]
The same can be done using
Space.call()
method:
>>> demo = server.space(0)
>>> demo.call("box.select_range", (0, 0, 2, 'AAAA'))
[('AAAA', 'Alpha'), ('BBBB', 'Bravo')]
Method Space.call()
is just
an alias for
Connection.call()