[Qt-interest] QtSql - fail to send blob data
Cyril
cyril.mailing.list at gmail.com
Thu Sep 8 16:29:14 CEST 2011
Thanks for your answers.
I am using MySQL server 5.5.8, MySQL database driver of Qt 4.7 , libmysql
6.0.2, under windows 7.
I tried the CONCAT syntax using hex-encoded blob but it still fails the same
way. Here is the code :
{
QSqlQuery q1(db);
q1.prepare("INSERT INTO t (id, data) VALUES(42, '')"); // field data is a
LONGBLOB
q1.exec();
}
QByteArray bigData; // several megabytes of data to insert in DB
const int chunkSize = 50000;
int i = 0;
while(!bigData.isEmpty()) {
QByteArray chunk = bigData.left(chunkSize);
bigData = bigData.mid(chunkSize);
QString str = QString::fromLatin1("UPDATE t SET data=CONCAT(data, 0x%1)
WHERE id=42").arg(QString(chunk.toHex()));
QSqlQuery q2(db);
q2.prepare(str);
q2.exec(); //<<<<<< still fails when i==max_allowed_packet/chunkSize
i++;
}
Note that this technique works fine when using phpmyadmin or any other mysql
interactive kind of console, which proves that the BLOB data doesn't get
mangled by CONCAT.
Anybody has an idea? Bug in QtSql?
Thanks
2011/9/7 Philipp Tkachev <zoonman at gmail.com>
> Jason,
> It's MySQL or MariaDB.
>
> max_allowed_packet is MySQL specific variable.
>
>
>
> --
> Sincerely, Philipp Tkachev.
> Jabber: zoonman at jabber.ru
> http://www.zoonman.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110908/bc9eb080/attachment.html
More information about the Qt-interest-old
mailing list