Description
Hi,
I am trying to call a function on tarantool which inserts given list input into a space. Function looks like below, it gets list, loop over records and inserts into a space named tester.
When I call the function within tarantool like the following, it works as expected and inserts records into the space.
tarantool> lst = {{1,'Test',1}, {2, 'Test2', 2}}
tarantool> batch_insert_tester(lst)
When I try to call the function through the library, it fails with the following error.
raise DatabaseError(self._return_code, self._return_message)
tarantool.error.DatabaseError: (32, '[string "function batch_insert_tester(list)..."]:4: attempt to index local 'record' (a number value)')
This is the code I have been using, as an input I am sending list of value tuples (tester space has 3 fields). How can I call a function with a list input like this?
connection = tarantool.connect(...)
tester_data = []
tester_data.append((3, 'ABBA', 3))
tester_data.append((4, 'ABBA', 4))
connection.call('batch_insert_tester', tester_data)
Here is the function defined on tarantool:
function batch_insert_tester(list)
box.begin()
for _, record in ipairs(list) do
box.space.tester:replace{record[1], record[2], record[3]}
end
box.commit()
end