I have an sql (text file) with a long transaction to create a database.
I am using Kompex sqlite c++ library for this:
// open database
Kompex::SQLiteDatabase *pDatabase = new Kompex::SQLiteDatabase(CT2A(strDBFilename), SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
// create statement instance for sql queries/statements
Kompex::SQLiteStatement *pStmt = new Kompex::SQLiteStatement(pDatabase);
strSQLCreateDB=get_file_contents(strSQLFilename).c_str(); // load the SQL file
try {
pStmt->Sql(strSQLCreateDB);
pStmt->ExecuteAndFree();
} catch(Kompex::SQLiteException &exception)
{
std::cerr << "Exception Occured" << std::endl;
exception.Show();
}
pDatabase->Close();
The database is created with 0 bytes and no errors. I am interested in any sample code even without the kompex library, to execute this sql transaction which creates the db.
executing the database from sqlite browser creates the database without errors.
this is a part of the SQL command file
/* Disable Foreign Keys */
pragma foreign_keys = off;
/* Begin Transaction */
begin transaction;
/* Database [scanlog(1)] */
pragma auto_vacuum=0;
pragma encoding='UTF-8';
pragma page_size=1024;
/* Drop table [ApplicationNames] */
drop table if exists [ApplicationNames];
/* Table structure [ApplicationNames] */
CREATE TABLE [ApplicationNames] (
[Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[ApplicationName] TEXT,
[Icon] TEXT);
CREATE INDEX [IndexApps] ON [ApplicationNames] ([Id], [ApplicationName]);
/* Data [ApplicationNames] */
insert into [ApplicationNames] values(1, 'Windows System', null);
insert into [ApplicationNames] values(2, 'Internet Explorer', null);
insert into [ApplicationNames] values(3, 'Google Chrome', null);
/* Commit Transaction */
commit transaction;
/* Enable Foreign Keys */
pragma foreign_keys = on;