paurkedal / ocaml-caqti

Cooperative-threaded access to relational data
https://paurkedal.github.io/ocaml-caqti/index.html
GNU Lesser General Public License v3.0
303 stars 36 forks source link

Transactions? #37

Closed xguerin closed 4 years ago

xguerin commented 4 years ago

The README mentions supports for transactions. I perused the interface but did not see any function related to transactions. Is it as simple as framing multiple exec with exec "BEGIN" and exec "COMMIT" ?

paurkedal commented 4 years ago

The connections modules have dedicated functions start, commit, and rollback for dealing with transactions. (Your approach would work though, at least for PostgreSQL and Sqlite3 where this is precisely how the functions are implemented.)

xguerin commented 4 years ago

Thanks for your answer. I does, indeed work quite well. I'll take a look at those functions. Sorry for not finding them, I must have been one coffee short of the right amount when I perused the doc :)