View Full Version : insert binary data into sqlite
sattu
24th March 2011, 13:00
Hi everyone,
I am using qt 4.7.I am trying to store binary data.My binary data is present in QByteArray.
Can any one tell me how to insert ? What is the create and insert statement ?
thanks
high_flyer
24th March 2011, 13:09
http://www.qtcentre.org/threads/39721-Inserting-PNG-into-Database-Escaping-String?highlight=BLOB
stampede
24th March 2011, 13:13
I think you can use BLOB datatype for the data field, so create could look like:
CREATE TABLE test( data BLOB NOT NULL );
and insert QByteArray as any other value, for example:
QByteArray bytes;
...
QSqlQuery query(db);
query.prepare("INSERT INTO test(data) VALUES(:data);");
query.bindValue(":data",bytes);
query.exec();
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.