I don't think it's that simple as you try to make it, at least if you want to include the data too.
Few years ago I had a similar problem and I wrote a function for that purpose. I'm copying-pasting the code from my old post after some reformatting to be readable. Although I have improved the code a bit since then in my own app, this should help you get started (please check the indentation, some fixes may be needed). This function doesn't transfer the schema, but I think it's easy to include it.
And then batch execute the sql file like this:... exportTables(); QSqlQuery query(targetDb); QFile f(QDir::homePath()+"/myDump.sql"); f.open(QIODevice::ReadOnly | QIODevice::Text); if(!query.exec(f.readAll())) qCritical() << "Can't execute sql file: " << query.lastError().text();