AFAIK, all of us must programming to database through database wrapper/manager for example sqliteman or CppSQLite.

However the database wrapper is specific to one sort of database which is not convenient for programmer cause require lots of modification just in case the database was cahnged.

Therefore, i must write a normal database wrapper that may interface with assorted type of database.

I've produce 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'll use traits the obtain the information type in line with the template argument provided.

This template argument is really a class type based on this base class for example sqlite, postgresql and mysql.

So, any suggestion or recommendation to my design.

How to produce a generic database interface and forward call towards the specific database interface library.

EDIT:

What's the different between ODBC and C++ Database Access Library(Soci ) ?

Help.

Thanks.

ODBC may be the protocol. It's open database connectivity, which defines functions that your database should expose to ensure that the consumer may use it within their C/C++ code. Normally the databases provides their very own ODBC compliant driver. Soci may be the library which does something you want. It's a library, so it should be getting it's own implementation which you'll directly use.

1 connection for every table access, you'd swap your database network usage. Create Connection class, connection particulars, ideally a static implementation and employ it like a component(Composition) individuals class.

Keep the connection independent off your database transactions. If a person transaction fails, atleast you are able to preempt the thread and employ exactly the same connection particulars for next transaction. You should use exactly the same connection for multiple databse tries, instead of creating 1 connection/table access.

This isn't really an response to your unique question, but how about using Soci? It will support sqlite, postgresql and mysql, in addition to Oracle, Firebird and ODBC.