Caqti transaction examples

EDIT: pauerkedal updated the oneshot documentation and it is now much clearer

is anyone familiar with caqti and transactions?

I’m getting errors like Invalid concurrent usage of PostgreSQL connection detected and:

  • can’t figure out what’s wrong
  • don’t find such errors in the source code

more details:

this is the gist:

  • I start a connection with Connection.start ()
  • then I execute different queries
let query = Caqti_request.exec Caqti_type.unit file_contents in
Connection.exec query ()

  * if nothing failed -> `Connection.commit ()`
  * if something failed -> `Connection.rollback ()`