[odb-users] design questions: c++ / python / sqlite
MM
finjulhich at gmail.com
Thu May 22 12:49:16 EDT 2014
On 16 May 2014 05:09, Boris Kolpackov <boris at codesynthesis.com> wrote:
> Hi,
>
> MM <finjulhich at gmail.com> writes:
>
> > The question is general in itself: What should the order of things be?
> >
> > 1. Step by step addition of odb pragmas to the C++ code to generate the
> sql
> > tables?
> > 2. Use of these tables from python, perhaps through some c++/python
> adapter
> > like swig or some layer like that?
>
> If you want ODB schema evolution support then ODB will have to generate
> and maintain the database schema. Or, to put it another way, your C++
> classes will have to be the "primary specification" of your data model.
> The good news is that ODB generates pretty idiomatic SQL (in other words,
> something that a database administrator would normally write by hand).
> You can also customize the resulting schema with the various pragmas,
> if you wish.
>
Ok, so ODB will master the db generation.
Regarding the Python part, I would suggest that you use one of the
> Python database access packages (I have heard there are some good
> ones) rather than try to access the C++ classes or the ODB API via
> something like Swig, etc. Unless you for some reason need to modify
> the C++ class state in the application's memory rather than in the
> database. And in that case I would probably look into Boost.Python
> first.
>
I just meant that a given class is defined in C++. I would expose that
class in python with boost.python perhaps, and then use those classes in
python to access the sqlite db through python.sqlite
>
> Boris
>
Another question:
I have
ABClass (with pure virtual fcts, and protected data members: name and other
things.)
-> Derived1 : public ABClass
-> Derived2: public ABClass
...
-> Derived10: public ABClass
In practise, I have only singletons of Derived1...Derived10. One instance
of each. They implement the base's virtual fcts and use the proctected data
members for that.
Is there a way to make this map to a single table that holds 10 rows where
the primary key is name, and the other things are other columns, and yet on
loading back from the table, that the correct concrete instances are
created?
If not, how to change my simple class hierarchy?
Thanks
More information about the odb-users
mailing list