[odb-users] odb question
Boris Kolpackov
boris at codesynthesis.com
Sat Aug 16 08:07:10 EDT 2014
Hi Ravil,
Nugmanov, Ravil (GE Energy Management) <ravil.nugmanov1 at ge.com> writes:
> Looking at the examples, I can see that the type of data base (MSQ SQL
> or MySQL for example) should be selected before compilation, using
> preprocessor definition. So there is no way to build the application
> once, and then select data base at runtime, correct? Looks like that
> separate binaries must be built for each target database, correct?
There is multi-database support. You can even load support code for
a particular database dynamically. The examples do it this way (i.e.
compile-time, single-database support) for simplicity. For details,
see Section 16, "Multi-Database Support" in the ODB manual.
> Second question is about automatic creation of tables in the database.
> When I started the c++11-mssql-vc11 project, I was expecting that it
> would create tables in the database automatically. But that did not
> happen. So tables should be created before running this test, there
> is no support for automatic table creation, right?
There is support for automatic table creation. ODB can generate the
necessary DDL statements either into a separate .sql file (default
for client-server databases such as SQL Server) or embedded into
the generated C++ code (default for embedded databases such as
SQLite). See Section 3.4, "Database" in the ODB manual for details.
What's more, ODB also supports automatic database schema evolution,
not only creation. That functionality is described in Chapter 13.
Boris
More information about the odb-users
mailing list