[odb-users] a odb connection map to multi database instance

Boris Kolpackov boris at codesynthesis.com
Wed Jan 7 04:49:59 EST 2015


newzai.chen <newzai.chen at anchormobile.com> writes:

> 1. on mysql ,has multi database
> 2. I want using one odb connection to operator multi database .

I am not sure what you mean by "operator". If you want to map
persistent classes to tables in different databases, then this
is possible (statically) using the database schema support in
ODB. See Section 14.1.8, "schema" in the ODB manual for details.

Alternatively, you can use the mysql_select_db() MySQL C API
function to change the default database on a connection. For

namespace mysql = odb::mysql;

mysql::database db (...);
mysql::connection_ptr cp (db.connection ());
mysql_select_db (cp->handle (), "my_other_db");


More information about the odb-users mailing list