Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » More .sch files?
More .sch files? [message #34811] Tue, 13 December 2011 16:54 Go to next message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member
I asked my how to make use of more than one .sch file, I mean if I want to use more than 1 sqlite3 database and want to use schema files?

For one it is clear, first I tell which file I want to use
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <urlaub/urlaub.sch>

and then
SqlSchema sch(SQLITE3);
    All_Tables(sch);
    SqlPerformScript(sch.Upgrade());
    SqlPerformScript(sch.Attributes());

but I can't see how to specify more than one file for more than one database!
Re: More .sch files? [message #34816 is a reply to message #34811] Tue, 13 December 2011 17:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Wolfgang wrote on Tue, 13 December 2011 10:54

I asked my how to make use of more than one .sch file, I mean if I want to use more than 1 sqlite3 database and want to use schema files?

For one it is clear, first I tell which file I want to use
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <urlaub/urlaub.sch>

and then
SqlSchema sch(SQLITE3);
    All_Tables(sch);
    SqlPerformScript(sch.Upgrade());
    SqlPerformScript(sch.Attributes());

but I can't see how to specify more than one file for more than one database!


If I understand well where the problem is:

You can specify SqlSession as first SqlPerformScript parameter.

It is true that using more databases is somewhat more diffult, it is recommened to add NOAPPSQL config flag - that kicks out global SQL (and new SQLR), which is usually a source of errors in multidb apps...

Mirek
Re: More .sch files? [message #34825 is a reply to message #34816] Tue, 13 December 2011 21:31 Go to previous messageGo to next message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member
thank you for answer but how to tell the SqlSession which .sch file it should use?

do you told me this - or?
Sqlite3Session sql_db1;
Sqlite3Session sql_db2;

if (!sql_db1.Open(path)) { /* break */ }
if (!sql_db2.Open(path)) { /* break */ }

SqlSchema sch(SQLITE3);

All_Tables(sch);
SqlPerformScript(sql_db1, sch.Upgrade());
SqlPerformScript(sql_db1, sch.Attributes());

SqlPerformScript(sql_db2, sch.Upgrade());
SqlPerformScript(sql_db2, sch.Attributes());


I understand how to tell SqlPerformScript which session it should perform but I dont see the connection between
#define MODEL <urlaub/urlaub.sch>

and
SqlSchema sch(SQLITE3);
Re: More .sch files? [message #34833 is a reply to message #34825] Wed, 14 December 2011 07:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Wolfgang wrote on Tue, 13 December 2011 15:31

thank you for answer but how to tell the SqlSession which .sch file it should use?

do you told me this - or?
Sqlite3Session sql_db1;
Sqlite3Session sql_db2;

if (!sql_db1.Open(path)) { /* break */ }
if (!sql_db2.Open(path)) { /* break */ }

SqlSchema sch(SQLITE3);

All_Tables(sch);
SqlPerformScript(sql_db1, sch.Upgrade());
SqlPerformScript(sql_db1, sch.Attributes());

SqlPerformScript(sql_db2, sch.Upgrade());
SqlPerformScript(sql_db2, sch.Attributes());


I understand how to tell SqlPerformScript which session it should perform but I dont see the connection between
#define MODEL <urlaub/urlaub.sch>

and
SqlSchema sch(SQLITE3);



I see...

Well, it is all a bit complicated, however:

All_Tables

is static. So if you need more databases with different models, you have to place those schema includes in different files, mark them "no blitz" and create schema upload in each file.
Re: More .sch files? [message #34837 is a reply to message #34833] Wed, 14 December 2011 08:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Another, perhaps better, but currently unexplored option for this case would be to enclose the schema includes in namespace...

(Frankly, this "more models per application" scenarion is really rare, that is why it remains unexplored).
Re: More .sch files? [message #34838 is a reply to message #34811] Wed, 14 December 2011 09:26 Go to previous message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member
i see, thank you.
Previous Topic: sql + editstring
Next Topic: BUG with "Run to cursor (in debug)"
Goto Forum:
  


Current Time: Fri Mar 29 14:44:12 CET 2024

Total time taken to generate the page: 0.01130 seconds