I am working on a QT program where I have to create two SQLite tables and insert data into one of them. I have a void function called configuraBaseDatos that does it in runtime. How can I get it at compile time?
Here's what I tried:
void configuraBaseDatos()
{
QSqlQuery q;
q.exec("CREATE TABLE IF NOT EXISTS vendedor(id INTEGER PRIMARY KEY NOT NULL,"
"nombre TEXT NOT NULL UNIQUE, clave TEXT NOT NULL, isAdmin TEXT NOT NULL)");
q.exec("INSERT INTO vendedor (id, nombre, clave,isAdmin) VALUES (1,'admin', '123456', 'Administrador')");
q.exec("CREATE TABLE IF NOT EXISTS producto(id INTEGER PRIMARY KEY NOT NULL,"
"nombre TEXT NOT NULL, marca TEXT NOT NULL , precio DOUBLE NOT NULL, cantidad INT NOT NULL)");
}
I also tried to use constexpr but the QSqlQuery is not a literal type. I think that templates could be a solution but I can't figure out how I can use it.