tarantool-python
tarantool-python copied to clipboard
Managing Transactions
Hi,
Is there a way to manage transactions through the library?
In tarantool, transaction is started with box.begin() and committed with box.commit() functions. But I couldn't find any methods in the library to manage the transactions.
What I would like to do is, begin a transaction, make updates/inserts to a space and then commit the transaction.
I tried adding some functions like below and calling these functions from the library, but it didn't work.
function begin_transaction(dummy) box.begin() end
function commit_transaction(dummy) box.commit() end
Thank you.
Hi! Tarantool doesn't have interactive transactions (https://github.com/tarantool/tarantool/issues/2016)
You should call box.begin() and box.commit() inside one tarantool event loop iteration. Also you couldn't yield inside transactions. There is only one way to insert/update/... data transactionally from connector - write stored procedure with transaction inside and call it.
So, you can read more about transaction management in Tarantool in our documentation https://www.tarantool.io/en/doc/2.5/book/box/atomic/
I'll left the issue open as the feature requested blocked on the corresponding tarantool functionality.
Thank you for the answer.
There is only one way to insert/update/... data transactionally from connector - write stored procedure with transaction inside and call it.
I was trying to implement such solution and stuck with this https://github.com/tarantool/tarantool-python/issues/162 Do you have any idea on this? Sample codes inside the documentation are somewhat limited and I couldn't figure out how to call a function with a list input.
Thank you.
I was trying to implement such solution and stuck with this #162
Answered, discussed and resolved :)
https://github.com/tarantool/tarantool/issues/2016 is implemented now, the issue is not blocked anymore.