Create a connection to the Tarantool server.
Parameters: | |
---|---|
Return type: | |
Raise : | NetworkError |
Represents connection to the Tarantool server.
This class is responsible for connection and network exchange with the server. Also this class provides low-level interface to data manipulation (insert/delete/update/select).
Initialize a connection to the server.
Parameters: |
---|
Parameters: | schema (Schema or dict) – Data schema (see Developer guide and Schema) |
---|
Execute CALL request. Call stored Lua function.
Parameters: |
|
---|---|
Return type: | Response instance |
Close connection to the server
Create connection to the host and port specified in __init__(). Usually there is no need to call this method directly, since it is called when you create an Connection instance.
Raise : | NetworkError |
---|
Execute DELETE request. Delete single record identified by key (using primary index).
Parameters: |
|
---|---|
Return type: | Response instance |
Execute INSERT request. It will throw error if there’s tuple with same PK exists.
Parameters: | |
---|---|
Return type: | Response instance |
Execute PING request. Send empty request and receive empty response from server.
Returns: | response time in seconds |
---|---|
Return type: | float |
Execute REPLACE request. It will throw error if there’s no tuple with this PK exists
Parameters: | |
---|---|
Return type: | Response instance |
Execute SELECT request. Select and retrieve data from the database.
Parameters: |
|
---|---|
Return type: | Response instance |
Select one single record (from space=0 and using index=0) >>> select(0, 0, 1)
Select several records using single-valued index >>> select(0, 0, [1, 2, 3]) >>> select(0, 0, [(1,), (2,), (3,)]) # the same as above
Select serveral records using composite index >>> select(0, 1, [(1,‘2’), (2,‘3’), (3,‘4’)])
Select single record using composite index >>> select(0, 1, [(1,‘2’)]) This is incorrect >>> select(0, 1, (1,‘2’))
Create Space instance for particular space
Space instance encapsulates the identifier of the space and provides more convenient syntax for accessing the database space.
Parameters: | space_name (int or str) – identifier of the space |
---|---|
Return type: | Space instance |
Execute STORE request. It will overwrite tuple with the same PK, if it exists, or inserts if not
Parameters: | |
---|---|
Return type: | Response instance |
Execute UPDATE request. Update single record identified by key (using primary index).
List of operations allows to update individual fields.
Parameters: |
|
---|---|
Return type: | Response instance |
A class used to describe a data schema. Encapsulates the names and types and provides more convenient syntax for database operations.
Create Schema instance.
Parameters: |
|
---|
Example schema description:
>>> schema = {
0: { # Space description
'name': 'users', # Space name
# Type that used to decode fields that are not listed below
'default_type': tarantool.STR,
'fields': {
0: ('user_id', tarantool.NUM), # (field name, field type)
1: ('num64field', tarantool.NUM64),
2: ('strfield', tarantool.STR),
# Alternative syntax
#2: { 'name': 'strfield', 'type': tarantool.STR },
#2: tarantool.STR # Alternative syntax
},
'indexes': {
0: ('pk', [0]), # (name, [field_no])
#0: { 'name': 'pk', 'fields': [0]}, # Alternative syntax
#0: [0], # Alternative syntax
}
}
}
Return index number by space name and index name
Parameters: |
---|
Convert a list of keys from Python to Tarantool types using schema
Parameters: | |
---|---|
Returns: | packed values |
Return type: | bytes |
Convert single field from Python type to Tarantol type
Parameters: |
|
---|---|
Returns: | packed value |
Return type: | bytes |
Convert a list of fields from Python to Tarantool types using schema
Parameters: |
|
---|---|
Returns: | packed tuple |
Returns: | packed values |
Convert field type from Tarantool type to Python type
Parameters: |
|
---|---|
Returns: | converted value |
Return type: | value of native python type (one of bytes, int, unicode (str for py3k)) |
Convert a list of fields from Tarantool to Python types using schema
Parameters: |
|
---|---|
Returns: | converted tuple value |
Return type: | unpacked values of native python types (bytes, int, unicode (or str for py3k)) |
Base class for error exceptions
Error related to the database engine
Error related to network
Warning related to network
Warning is emited in case of server return completion_status == 1 (try again)