Changeset 4b8ce66


Ignore:
Timestamp:
06/22/11 23:33:29 (10 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
06eef78
Parents:
c8b84e1
Message:

The database is now created from the program. We don't need to copy or provide fosdem.sqlite anymore.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/db.qrc

    rc8b84e1 r4b8ce66  
    11<!DOCTYPE RCC><RCC version="1.0">
    22<qresource>
    3     <file>fosdem.sqlite</file>
     3    <file>create_tables.sql</file>
    44</qresource>
    55</RCC>
  • src/sql/sqlengine.cpp

    rc8b84e1 r4b8ce66  
    5151    if(!QFile::exists(aDatabaseName)) // the DB (tables) doesn't exists, and so we have to create one
    5252    {
    53         // copy conference Db from resource, instead of creating
    54         // empty tables and then parsing the schedule
    55         QFile dbFile(aDatabaseName);
    56         QFile(":/fosdem.sqlite").copy(aDatabaseName);
    57         dbFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::WriteGroup);
    58         database.open();
     53        // create Db
     54        if (!database.open()) qDebug() << "Could not open database" << database.lastError();
     55        QFile file(":/create_tables.sql");
     56        file.open(QIODevice::ReadOnly | QIODevice::Text);
     57        QString allSqlStatements = file.readAll();
     58        foreach(QString sql, allSqlStatements.split(";")) {
     59            QSqlQuery query(database);
     60            if (!query.exec(sql)) qDebug() << "Could not execute query" << query.lastError();
     61        }
    5962    }
    6063    else
Note: See TracChangeset for help on using the changeset viewer.