Hello to all, AFAIK, we all must programming to database through database wrapper/manager such as sqliteman or CppSQLite.
But the database wrapper is specific to one type of database and this is not convenient for programmer cause require a lot of modification in case the database was cahnged.
Therefore, i would like to write a generic database wrapper that can interface with various kind of database.
I have create a class template like below.
template<typename T>
class ClsDatabaseManager
{
public:
// Pure Virtual Function
// All derived classes must implements it and forward the call
// appropriate database wrapper
connect(string);
disconnect(string);
Execute(string);
CreateTable(string);
CreateDatabase(string);
private:
T m_table;
T m_database;
};
class sqliteManager : public ClsDatabaseManager<T>
{
// Implement all the function by forward the call
};
Therefore, i will use traits the get the information type based on the template argument supplied.
This template argument is a class type derived from this base class such as sqlite, postgresql and mysql.
So, any suggestion or recommendation to my design.
How to create a generic database interface and forward call to the specific database interface library.
EDIT:
What is the different between ODBC and C++ Database Access Library(Soci ) ?
Please help.
Thanks.