I am writing a QT GUI application that will import a .csv file to a sqlite database table my .csv file is in the path /home/aj/import_table.csv and my database is in /home/aj/testdatabase.db
i wrote the below code block---
void MainWindow::on_importButton_clicked()
{
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("/home/aj/testdatabase.db");
QString querystr;
querystr=QString(".separator ","");
QSqlQuery query(querystr,db);
if(query.exec())
{
qDebug()<<"SUCCESSFULLY QUEIRED ";
QString querystr2;
querystr=QString(".import import_table.csv test_table");
}
else
{
qDebug()<<"ERROR DURING QUERY "<<db.lastError().text();
}
}
but it is throwing error at compile time--
/home/aj/sqlite3test/mainwindow.cpp:34: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive]
/home/aj/sqlite3test/mainwindow.cpp:34: error: conversion from ‘const char [1]’ to ‘QChar’ is ambiguous
/home/aj/sqlite3test/mainwindow.cpp:34: error: conversion from ‘const char [1]’ to ‘QChar’ is ambiguous
/usr/local/Trolltech/Qt-4.8.4/include/QtCore/qstring.h:90: error: initializing argument 1 of ‘QString::QString(int, QChar)’ [-fpermissive]
any solutions ???
is it happening because .separator and .import are sqlite terminal command and cannot be executed via the querystr=Qstring("... ... ..."); format ???