简体   繁体   中英

postgresql query c++ callback

Is it possible with any existing c++ library to implement a callback that returns when a query is completed?

I've found this , but I'm not sure if that's what I want.

I'd like to wait the boost::thread writing to the database until the write is completed.

If this is possible, please link the library and an example.

I was looking for something like this too, ended up doing an async libpq wrapper: http://github.com/metherealone/postgrespp - It uses Boost.ASIO though, not threads. I hope this helps.

From the libpq docs about PQexec function :

Submits a command to the server and waits for the result.

Similar to that, the PQexecParams and PQexecPrepared also wait for the query to be executed. So, using those functions you don't need to worry about waiting, the API will do that for you.

If you need to asynchronously send query to the database, you can use the asynchronous functions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM