Properly catch and handle database errors

Do not use a singleton for the database.

fix #3203
This commit is contained in:
louiz’
2016-07-12 00:31:57 +02:00
parent 03feb403f8
commit 4c1b9abe7e
6 changed files with 47 additions and 40 deletions
+3 -3
View File
@@ -26,7 +26,7 @@ public:
template<typename PersistentType>
static size_t count()
{
return litesql::select<PersistentType>(Database::get_db()).count();
return litesql::select<PersistentType>(*Database::db).count();
}
/**
* Return the object from the db. Create it beforehand (with all default
@@ -42,11 +42,11 @@ public:
const std::string& channel);
static void close();
static void open(const std::string& filename, const std::string& db_type="sqlite3");
private:
static std::unique_ptr<db::BibouDB> db;
static db::BibouDB& get_db();
};
#endif /* USE_DATABASE */