1# -*- coding: utf-8 -*- 2# pylint: disable=C0301,W0105,W0401,W0614 3''' 4This module provides :class:`~tarantool.space.Space` class. 5It is an object-oriented wrapper for request over Tarantool space. 6''' 7 8 9class Space(object): 10 ''' 11 Object-oriented wrapper for accessing a particular space. 12 Encapsulates the identifier of the space and provides more convenient 13 syntax for database operations. 14 ''' 15 16 def __init__(self, connection, space_name): 17 ''' 18 Create Space instance. 19 20 :param connection: Object representing connection to the server 21 :type connection: :class:`~tarantool.connection.Connection` instance 22 :param int space_name: space no or name to insert a record 23 :type space_name: int or str 24 ''' 25 26 self.connection = connection 27 self.space_no = self.connection.schema.get_space(space_name).sid 28 29 def insert(self, *args, **kwargs): 30 ''' 31 Execute INSERT request. 32 33 See `~tarantool.connection.insert` for more information 34 ''' 35 return self.connection.insert(self.space_no, *args, **kwargs) 36 37 def replace(self, *args, **kwargs): 38 ''' 39 Execute REPLACE request. 40 41 See `~tarantool.connection.replace` for more information 42 ''' 43 return self.connection.replace(self.space_no, *args, **kwargs) 44 45 def delete(self, *args, **kwargs): 46 ''' 47 Execute DELETE request. 48 49 See `~tarantool.connection.delete` for more information 50 ''' 51 return self.connection.delete(self.space_no, *args, **kwargs) 52 53 def update(self, *args, **kwargs): 54 ''' 55 Execute UPDATE request. 56 57 See `~tarantool.connection.update` for more information 58 ''' 59 return self.connection.update(self.space_no, *args, **kwargs) 60 61 def upsert(self, *args, **kwargs): 62 ''' 63 Execute UPDATE request. 64 65 See `~tarantool.connection.upsert` for more information 66 ''' 67 return self.connection.upsert(self.space_no, *args, **kwargs) 68 69 def select(self, *args, **kwargs): 70 ''' 71 Execute SELECT request. 72 73 See `~tarantool.connection.select` for more information 74 ''' 75 return self.connection.select(self.space_no, *args, **kwargs) 76 77 def call(self, func_name, *args, **kwargs): 78 ''' 79 Execute CALL request. Call stored Lua function. 80 81 It's deprecated, use `~tarantool.connection.call` instead 82 ''' 83 return self.connection.call(func_name, *args, **kwargs) 84