QFile::remove( dbName
);
// delete sqlite file if it exists from a previous run db.setDatabaseName( dbName );
db.open();
//Create Tables
query.prepare("CREATE TABLE IF NOT EXISTS misin_species_list (cname VARCHAR, family VARCHAR, fdetail VARCHAR, genus VARCHAR, id VARCHAR, kingdom VARCHAR, species VARCHAR, habit VARCHAR)");
if(!query.exec()){
qDebug()<<"error:" << query.lastError().text();
}
queryanimals.prepare("CREATE TABLE IF NOT EXISTS misin_factsheet_animals (cname VARCHAR, description VARCHAR, edrr VARCHAR, family VARCHAR, fdetail VARCHAR, genus VARCHAR, habitat VARCHAR, hdetail VARCHAR, id VARCHAR, damage VARCHAR, reproduction VARCHAR, similar VARCHAR, source VARCHAR, species VARCHAR)");
if(!queryanimals.exec()){
qDebug()<<"error:" << queryanimals.lastError().text();
}
queryplants.prepare("CREATE TABLE IF NOT EXISTS misin_factsheet_plants(cname VARCHAR, description VARCHAR, duration VARCHAR, edrr VARCHAR, family VARCHAR,fdetail VARCHAR, flowers VARCHAR, fruitseeds VARCHAR, genus VARCHAR, habit VARCHAR, habitat VARCHAR, hdetail VARCHAR, id VARCHAR, impact VARCHAR, kingdom VARCHAR, leaves VARCHAR, pcode VARCHAR, reproduction VARCHAR, similar VARCHAR, source VARCHAR, species VARCHAR, stems VARCHAR, tmodule VARCHAR)");
if(!queryplants.exec()){
qDebug()<<"error:" << queryplants.lastError().text();
}
QString dbName( "mydatabase.db" );
QFile::remove( dbName ); // delete sqlite file if it exists from a previous run
QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE" );
db.setDatabaseName( dbName );
db.open();
//Create Tables
QSqlQuery query;
query.prepare("CREATE TABLE IF NOT EXISTS misin_species_list (cname VARCHAR, family VARCHAR, fdetail VARCHAR, genus VARCHAR, id VARCHAR, kingdom VARCHAR, species VARCHAR, habit VARCHAR)");
if(!query.exec()){
qDebug()<<"error:" << query.lastError().text();
}
QSqlQuery queryanimals;
queryanimals.prepare("CREATE TABLE IF NOT EXISTS misin_factsheet_animals (cname VARCHAR, description VARCHAR, edrr VARCHAR, family VARCHAR, fdetail VARCHAR, genus VARCHAR, habitat VARCHAR, hdetail VARCHAR, id VARCHAR, damage VARCHAR, reproduction VARCHAR, similar VARCHAR, source VARCHAR, species VARCHAR)");
if(!queryanimals.exec()){
qDebug()<<"error:" << queryanimals.lastError().text();
}
QSqlQuery queryplants;
queryplants.prepare("CREATE TABLE IF NOT EXISTS misin_factsheet_plants(cname VARCHAR, description VARCHAR, duration VARCHAR, edrr VARCHAR, family VARCHAR,fdetail VARCHAR, flowers VARCHAR, fruitseeds VARCHAR, genus VARCHAR, habit VARCHAR, habitat VARCHAR, hdetail VARCHAR, id VARCHAR, impact VARCHAR, kingdom VARCHAR, leaves VARCHAR, pcode VARCHAR, reproduction VARCHAR, similar VARCHAR, source VARCHAR, species VARCHAR, stems VARCHAR, tmodule VARCHAR)");
if(!queryplants.exec()){
qDebug()<<"error:" << queryplants.lastError().text();
}
To copy to clipboard, switch view to plain text mode
Bookmarks