Closed nobleread closed 4 years ago
Hi!
Obviously, ozo provides asynchronous API, but is there a way to execute some SQL in a blocking manner?
There are two ways:
io_context.run()
like in this test right after calling ozo::request
.boost::asio::use_future
and running io_context.run()
in a dedicated thread.Is there a way to use ozo without boost::asio maybe?
You may try to call libpq
functions directly in synchronous mode. The library entities provide access and can work with all the necessary native libpq
handlers.
Hi!
Thanks, your response was helpful. We decided to use 1. way. I would just like to add that can be helpful for somebody, to mention that if the application is running asynchronously in one io_context and we need synchronous blocking database request we need do it in another io_context.
Obviously, ozo provides asynchronous API, but is there a way to execute some SQL in a blocking manner? I've tried to perform synchronous, i.e. blocking, call to database, but am not sure how to do that without using any completion handlers. What I did instead was to pass some completion handler to ozo and then call boost::asio's
io_context.run_once()
. Is there a way to use ozo without boost::asio maybe? Or provide some fake completion handler, that forces application to wait until db call is finished?