def insert(self, space_name, values): if isinstance(space_name, str): sp = yield from self.schema.get_space(space_name) space_name = sp.sid res = yield from self._send_request(RequestInsert(self, space_name, values)) return res
def insert(self, space_name, values): ''' Execute INSERT request. It will throw error if there's tuple with same PK exists. :param int space_name: space id to insert a record :type space_name: int or str :param values: record to be inserted. The tuple must contain only scalar (integer or strings) values :type values: tuple :rtype: `Response` instance ''' if isinstance(space_name, string_types): space_name = self.schema.get_space(space_name).sid request = RequestInsert(self, space_name, values) return self._send_request(request)
def insert(self, space_name, values, return_tuple=False): '''\ Execute INSERT request. Insert single record into a space `space_name`. :param int space_name: space id to insert a record :type space_name: int or str :param values: record to be inserted. The tuple must contain only scalar (integer or strings) values :type values: tuple :param return_tuple: True indicates that it is required to return the inserted tuple back :type return_tuple: bool :rtype: `Response` instance ''' assert isinstance(values, tuple) request = RequestInsert(self, space_name, values, return_tuple) return self._send_request(request, space_name)
print "\n" print "IPROTO_CALL" test({IPROTO_CODE: REQUEST_TYPE_CALL}, {}) test({IPROTO_CODE: REQUEST_TYPE_CALL}, {IPROTO_KEY: ('procname', )}) print "\n" # gh-434 Tarantool crashes on multiple iproto requests with WAL enabled admin("box.cfg.wal_mode") admin("space = box.schema.space.create('test', { id = 567 })") admin("index = space:create_index('primary', { type = 'hash' })") admin("box.schema.user.grant('guest', 'read,write,execute', 'space', 'test')") c = Connection('localhost', server.iproto.port) c.connect() request1 = RequestInsert(c, 567, [1, "baobab"]) request2 = RequestInsert(c, 567, [2, "obbaba"]) s = c._socket try: s.send(bytes(request1) + bytes(request2)) except OSError as e: print ' => ', 'Failed to send request' response1 = Response(c, c._read_response()) response2 = Response(c, c._read_response()) print response1.__str__() print response2.__str__() request1 = RequestInsert(c, 567, [3, "occama"]) request2 = RequestSelect(c, 567, 0, [1], 0, 1, 0) s = c._socket try:
def pack(self, connection): return RequestInsert(connection, self.space_no, self.value_list)