0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 12:51:13 +08:00
sqlpp11/examples/connection_pool/src/db_connection.cpp
MeanSquaredError 7f04435576
Connection pools documentation and example (#533)
* Add an example of using a connection pool.

* Add documentation about the connection pools. Expand the documentation about multi-threading issues.
2023-10-03 09:45:21 +02:00

16 lines
336 B
C++

#include <memory>
#include <db_connection.h>
db_connection::pq_conn& db_connection::fetch()
{
if (m_conn_ptr == nullptr)
{
m_conn_ptr = sqlpp::compat::make_unique<pq_conn>(m_pool.get());
}
return *m_conn_ptr;
}
db_connection::db_connection(sqlpp::postgresql::connection_pool& pool) : m_pool{pool}, m_conn_ptr{nullptr}
{
}