简体   繁体   English

PostgreSQL查询C ++回调

[英]postgresql query c++ callback

Is it possible with any existing c++ library to implement a callback that returns when a query is completed? 现有的c ++库是否有可能实现在查询完成时返回的回调?

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. 我想wait boost::thread写入数据库,直到写入完成。

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. 我也在寻找类似的东西,最终做了一个异步libpq包装器: http ://github.com/metherealone/postgrespp-尽管它使用Boost.ASIO,而不是线程。 I hope this helps. 我希望这有帮助。

From the libpq docs about PQexec function : 从libpq文档中了解PQexec函数

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. 与此类似, PQexecParamsPQexecPrepared也等待查询被执行。 So, using those functions you don't need to worry about waiting, the API will do that for you. 因此,使用这些功能,您无需担心等待,API会为您完成。

If you need to asynchronously send query to the database, you can use the asynchronous functions . 如果您需要将查询异步发送到数据库,则可以使用异步函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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