add table creation and first table model.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include <QDebug>
|
||||
#include <QSqlQuery>
|
||||
|
||||
Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -51,6 +52,12 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
if(!QFile(db.databaseName()).exists())
|
||||
{
|
||||
QFile(db.databaseName()).open(QIODevice::ReadWrite);
|
||||
//Create table structure
|
||||
db.open();
|
||||
db.exec("CREATE TABLE vehicles (id INTEGER PRIMARY KEY, name TEXT, maker TEXT, model TEXT, year INTEGER, image TEXT);");
|
||||
db.exec("CREATE TABLE records (id INTEGER PRIMARY KEY, servicetype TEXT, date INTEGER, miles INTEGER, notes TEXT);");
|
||||
db.commit();
|
||||
db.close();
|
||||
}
|
||||
if(!db.open())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user