There is no such thing as "Qtsql". Qt provides an interfaces to SQL database engines that include MySQL, SQLite, PostgreSQL and several others. So far, the answer have been centered around putting the data into an SQLite database since that is what your code fragment showed. With that in mind, so I will keep on that track...
One way of doing the import would be to brute force the command line from within your code using a "system()" call.
system("sqlite mydatabase.db < some.sql");
system("sqlite mydatabase.db < some.sql");
To copy to clipboard, switch view to plain text mode
Another option would be to open the input file, read it, discard all comments, and then pass the queries to the database using QSqlQuery. [Since I am too lazy to figure out all of the Qt details of reading stuff from a file and then work out the simple parser, I'll skip the example code. :-) ] The advantage of this is that you can quickly determine when something fails to parse -- which brings me to my next point.
The bigger issue you will probably have to worry about is making sure the exported SQL from MySQL is something SQLite can handle. Each database engine tends to speak its own dialect of SQL. 90% of the language is the same (the SELECTs, INSERTs, etc.) but often the data types differ slightly. That's where you might run into some issues with importing.
Personally, if you have MySQL available on the platform you are going to be running the Qt app on, I would use MySQL for the database engine instead of SQLite so that you don't have to worry about the changing the sql. It's easy to do in your app, simply change "QSQLITE" to "QMYSQL".
db = QtSql.QSqlDatabase.addDatabase("QMYSQL")
To copy to clipboard, switch view to plain text mode
-John
Bookmarks