[odb-users] How to retrieve schema name ?

Per Edin info at peredin.com
Thu Mar 19 06:45:56 EDT 2015


Ah! I see. I'm sure native views can help you with that, untested
example from the top of my head:

#pragma db view query("SELECT name FROM schema_version GROUP BY name")
struct schema_name
{
  std::string name;
};

odb::result< schema_name > r(db.query< schema_name >());

Section 10.6 Native Views of the ODB manual should provide more details. :)

/Per


On Thu, Mar 19, 2015 at 11:20 AM, David Sarrut
<David.Sarrut at creatis.insa-lyon.fr> wrote:
>
> yes Per, sure ! Sorry I was not enough precise: I need to do this query
> within odb, in C++.
>
> I usually use things such as :
> typedef odb::query<person> query;
> typedef odb::result<person> result;
> etc ...
>
> but I need to know the type of this schema_version table to do that. Or
> maybe with native SQL query ? but in this case, it is not clear for me how
> to get the result.
>
> thanks,
> David
>
>
> On Thu, Mar 19, 2015 at 11:09 AM, Per Edin <info at peredin.com> wrote:
>>
>> Hi David!
>>
>> Maybe I have misunderstood your problem, but wouldn't a simple
>>
>> SELECT name FROM schema_version GROUP BY name
>>
>> work? To get all unique schema names in any database.
>>
>> /Per
>>
>> On Thu, Mar 19, 2015 at 10:55 AM, David Sarrut
>> <David.Sarrut at creatis.insa-lyon.fr> wrote:
>> > Hello,
>> >
>> > when create a db with a schema name, there is an additional table
>> > "schema_version" that is created. When reading a database, say from a
>> > file
>> > with sqlite, is there a way to access this table content and retrieve
>> > the
>> > value for the name ?
>> >
>> > thanks,
>> > David
>> >
>> > --
>> > David Sarrut, Phd
>> > Directeur de recherche CNRS
>> > CREATIS, UMR CNRS 5220, Inserm U 1044
>> > Centre de lutte contre le cancer Léon Bérard
>> > 28 rue Laënnec, 69373 Lyon cedex 08
>> > Tel : 04 78 78 51 51 / 06 74 72 05 42
>> > http://www.creatis.insa-lyon.fr/~dsarrut
>> > _________________________________
>> >  "2 + 2 = 5,  for extremely large values of 2"
>> > _________________________________
>
>
>
>
> --
> David Sarrut, Phd
> Directeur de recherche CNRS
> CREATIS, UMR CNRS 5220, Inserm U 1044
> Centre de lutte contre le cancer Léon Bérard
> 28 rue Laënnec, 69373 Lyon cedex 08
> Tel : 04 78 78 51 51 / 06 74 72 05 42
> http://www.creatis.insa-lyon.fr/~dsarrut
> _________________________________
>  "2 + 2 = 5,  for extremely large values of 2"
> _________________________________



More information about the odb-users mailing list