Hi,
I can't succeed in inserting a BLOG field into a sqlite 3 database with qsqlQuery (I use QT 4.3)
Here is the source code I use:
QByteArray *bytes1 = new QByteArray();
QBuffer pixBigBuf(bytes1);
pixBigBuf.open(QIODevice::WriteOnly);
pixBig.save(&pixBigBuf, "JPG");
Logger::log(Logger::errorLevel, QString("= = = =>") + QVariant(bytes1->size()).toString());
query.prepare("insert into media(filename,type,view, dataBig) values (:filename, :type, :view, :dataBig)");
query.bindValue(":filename",filename);
query.bindValue(":type",0);
query.bindValue(":view","none");
//bytes1.const
query.bindValue(":dataBig", bytes1->constData());
query.exec();
The size of the bytearray to insert is ok (11000) but after the insertion, the field takes only 4 bytes in the database...
However, If I use the sqlite command line tool, I succeed in inserting several bytes into the blob field.
I saw that some people succeeded by converting qbytearray into a qstring and replacing NULL and ' caracters by special ones to avoid insertion problem. Is it the way?
Best Regards,
Oscar
Bookmarks