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)) |