Home » U++ Library support » U++ SQL » Any way to generate sch from database?
Re: Any way to generate sch from database? [message #26161 is a reply to message #26135] |
Tue, 06 April 2010 15:00 |
|
mirek
Messages: 13980 Registered: November 2005
|
Ultimate Member |
|
|
Sorry for late reply. These functions is what are you looking for:
String ExportSch(SqlSession& session, const String& database);
String ExportIds(SqlSession& session, const String& database);
#ifndef NOAPPSQL
String ExportSch(const String& database);
String ExportIds(const String& database);
#endif
Here is example exporting schema from MySql:
#include <MySql/MySql.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
MySqlSession session;
// substitute your 'username' and 'password' here:
if(!session.Connect("root", "heslo", "test", "10.0.0.19")) {
printf("Can't connect with MySql\n");
return;
}
Sql sql(session);
sql.Execute("use test");
sql.Execute("show tables");
while(sql.Fetch())
Cout() << (String)sql[0] << '\n';
SaveFile("u:/lego.sch", ExportSch(session, "test"));
SaveFile("u:/legoid", ExportIds(session, "test"));
}
Note that no column attributes (contraints, keys, indicies) are exported.
Mirek
[Updated on: Tue, 06 April 2010 15:00] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu May 16 07:00:37 CEST 2024
Total time taken to generate the page: 0.02039 seconds
|