[DB] Use a single shared pool of connections to the database
This commit is contained in:
@@ -29,7 +29,9 @@ int main(void)
|
||||
// Set up the database session
|
||||
Database::Handler::configureAuth();
|
||||
|
||||
Database::Handler db("test_user.db");
|
||||
std::unique_ptr<Wt::Dbo::SqlConnectionPool> connectionPool( Database::Handler::createConnectionPool("test_user.db"));
|
||||
|
||||
Database::Handler db(*connectionPool);
|
||||
|
||||
Wt::Dbo::Transaction transaction(db.getSession());
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ int main(void)
|
||||
|
||||
boost::filesystem::remove("test.db");
|
||||
|
||||
Handler db("test.db");
|
||||
std::unique_ptr<Wt::Dbo::SqlConnectionPool> connectionPool(Database::Handler::createConnectionPool( "test.db"));
|
||||
|
||||
Handler db( *connectionPool );
|
||||
|
||||
// Create
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <Wt/Dbo/SqlConnectionPool>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
@@ -32,7 +32,9 @@ int main(void)
|
||||
std::cout << "Starting test!" << std::endl;
|
||||
|
||||
// Set up the long living database session
|
||||
Database::Handler database("test.db");
|
||||
std::unique_ptr<Wt::Dbo::SqlConnectionPool> connectionPool(Database::Handler::createConnectionPool( "test.db"));
|
||||
|
||||
Database::Handler database(*connectionPool);
|
||||
|
||||
Wt::Dbo::Transaction transaction(database.getSession());
|
||||
|
||||
@@ -40,7 +42,8 @@ int main(void)
|
||||
|
||||
std::cout << "Found " << tracks.size() << " tracks!" << std::endl;
|
||||
|
||||
BOOST_FOREACH(Database::Track::pointer track, tracks ) {
|
||||
for (auto track : tracks)
|
||||
{
|
||||
assert( !track->getName().empty() );
|
||||
assert( !track->getGenres().empty() );
|
||||
assert( !track->getDuration().is_not_a_date_time() );
|
||||
|
||||
Reference in New Issue
Block a user