[odb-users] dynamic multidatabase mysql
Boris Kolpackov
boris at codesynthesis.com
Fri Nov 11 08:03:23 EST 2016
[Forgot to keep odb-users CC'ed]
----- Original Message -----
From: "Boris Kolpackov" <boris at codesynthesis.com>
Subject: Re: [odb-users] dynamic multidatabase mysql
Date: Fri, 11 Nov, 2016 15:00 +0200
Hi Wolfgang,
Wolfgang Haupt <haupt.wolfgang at gmail.com> writes:
> In case of sqlite if the database is not yet created odb will create it.
> For mysql an empty database has to be there. I use the ctor like this:
>
> m_db = std::shared_ptr<odb::core::database>(new
> odb::mysql::database(settings.user, settings.pass, "common"));
>
> Can I omit the db name and let the schema catalogue create the db instead
> if it does not exist?
No, for client-server databases ODB is not going to create the database
automatically. Most of the time the user won't have the necessary
privileges. But if your users do, then you can use the CREATE DATABASE
statement[1]:
m_db->execute ("CREATE DATABASE IF NOT EXISTS <name>");
[1] http://dev.mysql.com/doc/refman/5.7/en/create-database.html
Boris
More information about the odb-users
mailing list