libsqlmm is a C++ library that allows you to use several (currently MySQL and PostgreSQL) databases without changing code.
Of course you may have to alter queries.
Example use:
SQL_Database DB = SQL_Connect(SQL_POSTGRESQL, 'db.example.com', 'main_db',
'www-db', 'secret-pass');
if (!DB.Connected())
cout << 'Failed to connect to SQL server.' << endl;
SQL_Tuples T = DB.Execute('SELECT * FROM my_table');
if (!T.Success())
cout << T.GetError().String() << endl;
for (int i = 0; i < T.NumTuples(); ++i)
{
for (int j = 0; j < T.NumFields(); ++j)
cout << '| ' << T.GetValue(i, j, 'NULL');
cout << endl;
}
Of course you may have to alter queries.
Example use:
SQL_Database DB = SQL_Connect(SQL_POSTGRESQL, 'db.example.com', 'main_db',
'www-db', 'secret-pass');
if (!DB.Connected())
cout << 'Failed to connect to SQL server.' << endl;
SQL_Tuples T = DB.Execute('SELECT * FROM my_table');
if (!T.Success())
cout << T.GetError().String() << endl;
for (int i = 0; i < T.NumTuples(); ++i)
{
for (int j = 0; j < T.NumFields(); ++j)
cout << '| ' << T.GetValue(i, j, 'NULL');
cout << endl;
}