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

newzai.chen newzai.chen at anchormobile.com
Wed Jan 7 05:12:08 EST 2015

thanks you..

mysql_select_db (cp->handle (), "my_other_db"); is very important..thanks you!!!!

From: Boris Kolpackov
Date: 2015-01-07 17:49
To: newzai.chen
CC: odb-users
Subject: Re: [odb-users] a odb connection map to multi database instance
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