I have a SQLite database which I do queries on by using QsqlQuery. If I want to enforce the ‘foreign_key’ constraint on the database I can set the query to be “PRAGMA foreign_key = 1”. Checking afterwards by creating a “PRAGMA foreign_key” query, the first value of next() is 1, so this does work as expected.
My problem is now if i want to configure the database in other ways like:
.separator ','
.import test.csv foo
, where the last line reads a .csv file and inserts it into the ‘foo’ table of the currently opened database.
In command line this is straight forward. I just open my SQLite database and run those two lines. Is it possible to run this on the SQLite database using QSqlQuery, or must I use QProcess or System()? System() works to fire up the command prompt, but I don’t know how to run the commands after this. Should i create a .bat file? Right now I am clueless and a little help would be greatly appreciated.
Thanks for the patience.
↧