taocpp / taopq

C++ client library for PostgreSQL
Boost Software License 1.0
265 stars 40 forks source link

question: calling execute on a threadpool #61

Closed TennisBowling closed 2 years ago

TennisBowling commented 2 years ago

can I call execute on a threadpool?

ex.

const auto conn = tao::pq::connection_pool::create("dbname=postgres user=postgres password=postgres");
conn->execute("CREATE TABLE IF NOT EXISTS fcu_data (VALUE TEXT);");

instead of conn->connection()->execute("CREATE TABLE IF NOT EXISTS fcu_data (VALUE TEXT);"); ?

d-frey commented 2 years ago

Yes, see https://github.com/taocpp/taopq/blob/main/doc/Connection-Pool.md#executing-statements

And it's not a thread pool, it's a connection pool. But you can make the above calls from multiple threads if you like.