[odb-users] Create odb class from sql schema / use an existent database

rkadeFR contact at rkade.fr
Wed May 29 12:01:25 EDT 2013

On 29/05/2013 14:27, Boris Kolpackov wrote:
> Hi,
> rkadeFR <contact at rkade.fr> writes:
>> I have an existent DB, and would like to map it to
>> some C++/ODB classes in order to use my DB.
>> Is there a possibility to generate the C++/ODB classes?
> Currently, there is no support for automatically generating
> C++ classes from database schema. But seeing that this feature
> is requested a lot, we are planning to add this support soon.
> I your case, would you prefer the C++ classes generated
> from a .sql file containing your table definitions or by
> connecting to the database directly?
I would rather have them generated from a .sql.
I don't have the database, but can have the dump of
the schema.

>> Or is there an efficient way for me using an existing DB
>> with my C++ program?
> Right now, if you want to use ODB with an existing database,
> then you will need to create and map your C++ classes manually.
> ODB allows you to map to custom tables, columns, and database
> types, for example:
> #pragma db table("PEOPLE")
> class person
> {
>    ...
>    #pragma db column("NAME") type("VARCHAR(50)")
>    std::string name;
> };
> There is also the 'schema/custom' example in the odb-examples package
> that shows how to do it.
> Boris
That's such a great feature !

Thank you for your quick answer

More information about the odb-users mailing list