module tarantool.schema

Schema types definitions. For internal use only, there is no API to use pre-build schema objects.

tarantool.schema.MAX_RECURSION_DEPTH = 32

Max possible known schema depth is 4 if foreign keys are used (since Tarantool 2.10), but there are no restrictions in protocol.

class tarantool.schema.Schema(con)

Contains Tarantool server spaces schema.

Parameters:

con (Connection) – Related Tarantool server connection.

fetch_index(space_object, index)

Fetch a single index space schema from the Tarantool server and build a schema object.

Parameters:
Return type:

SchemaIndex

Raises:

SchemaError, fetch_index_from() exceptions

fetch_index_all()

Fetch all spaces indexes schema from the Tarantool server and build corresponding schema objects.

Raises:

fetch_index_from() exceptions

fetch_index_from(space, index)

Fetch space index schema from the Tarantool server.

Parameters:
  • space (int or None) – Space id. If None, fetch all spaces index schema.

  • index (str or int or None) – Index name or id. If None, fetch all space indexes schema.

Returns:

Space index format data received from Tarantool.

Return type:

list or tuple

Raises:

select() exceptions

fetch_space(space)

Fetch a single space schema from the Tarantool server and build a schema object.

Parameters:

space (str or int) – Space name or space id to fetch.

Return type:

SchemaSpace

Raises:

SchemaError, fetch_space_from() exceptions

fetch_space_all()

Fetch all spaces schema from the Tarantool server and build corresponding schema objects.

Raises:

fetch_space_from() exceptions

fetch_space_from(space)

Fetch space schema from the Tarantool server.

Parameters:

space (str or int or None) – Space name or space id to fetch. If None, fetch all spaces.

Returns:

Space format data received from Tarantool.

Return type:

list or tuple

Raises:

select() exceptions

flush()

Clean existing schema data.

get_field(space, field)

Get space field format info.

Parameters:
  • space (str or int) – Space name or space id.

  • field (str or int) – Field name or field id.

Returns:

Field format info.

Return type:

dict

Raises:

SchemaError, fetch_space() exceptions

get_index(space, index)

Get space index schema. If it exists in the local schema, return local data, otherwise fetch data from the Tarantool server.

Parameters:
  • space (str or int) – Space id or space name.

  • index (str or int) – Index id or index name.

Return type:

SchemaIndex

Raises:

fetch_index() exceptions

get_space(space)

Get space schema. If it exists in the local schema, return local data, otherwise fetch data from the Tarantool server.

Parameters:

space (str or int) – Space name or space id.

Return type:

SchemaSpace

Raises:

fetch_space() exceptions

class tarantool.schema.SchemaIndex(index_row, space)

Contains schema for a space index.

Parameters:
  • index_row (list or tuple) – Index format data received from Tarantool.

  • space (SchemaSpace) – Related space schema.

Raise:

SchemaError

flush()

Clean existing index data.

class tarantool.schema.SchemaSpace(space_row, schema)

Contains schema for a space.

Parameters:
  • space_row (list or tuple) – Space format data received from Tarantool.

  • schema (Schema) – Related server schema.

Raise:

SchemaError

flush()

Clean existing space data.