tarantool / tarantool-python

Python client library for Tarantool
https://www.tarantool.io
BSD 2-Clause "Simplified" License
98 stars 48 forks source link

Managing Transactions #163

Open enescaglar opened 3 years ago

enescaglar commented 3 years ago

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.

olegrok commented 3 years ago

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/

Totktonada commented 3 years ago

I'll left the issue open as the feature requested blocked on the corresponding tarantool functionality.

enescaglar commented 3 years ago

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.

Totktonada commented 3 years ago

I was trying to implement such solution and stuck with this #162

Answered, discussed and resolved :)

Totktonada commented 2 years ago

https://github.com/tarantool/tarantool/issues/2016 is implemented now, the issue is not blocked anymore.