[odb-users] Generating model.hxx from pre-existing schema

Boris Kolpackov boris at codesynthesis.com
Tue Jun 19 02:18:05 EDT 2012


Hi Alex,

Alex Hurd <hurdad at gmail.com> writes:

> Has anyone built a script to generate a model.hxx file from a pre existing
> database schema? Basically the reverse of the odb compiler (model.hxx to
> model.sql).

We have this on our TODO list since quite a few people seem to be
interested in this feature. Of course the ODB compiler won't be
able to do a stellar job in all the cases since there could be
multiple ways to map SQL tables to C++. For example, two tables
with a relationship between them can be mapped to two persistent
objects or it can be a persistent object and a container. So we
might also have to provide a way to give ODB some hints about how
to map things.

Also, we haven't decided what will be the input format for this
feature. The natural way would be to use an SQL file with the DDL
statements but in this case we will have to parse all the different
SQL dialects. The other option is to query the database itself using
the API. While this sidesteps the whole SQL parsing issue, it has its
own drawbacks, such as dependency on all the database runtimes, as
well as the need to be able to access the database during compilation.

Which approach do you think will work better in your case?

Boris



More information about the odb-users mailing list