goocreations
12th September 2010, 18:15
I have a Postgres database with a BYTEA field.
I want to insert bytes into this fields.
I'm currently doing this:
QByteArray data = <get data>;
QString query = "INSERT INTO images (id, bytes) VALUES (1, :data)";
QSqlQuery sql(query);
sql.bindValue(":data", data);
sql.exec();
This failes and I get the following error:
ERROR: syntax error at or near "("
LINE 1: EXECUTE ('\\000\\000\\000\\000\\000\\000\\000\\000\\000\\0 0...
If I replace the :data with NULL, everything works fine.
Does anyone know how to insert binary dat into Postgres using QSqlDatabase and QSqlQuery.
Any reference to an online tutorial will also be greate, because I can't find one.
Thank you
I want to insert bytes into this fields.
I'm currently doing this:
QByteArray data = <get data>;
QString query = "INSERT INTO images (id, bytes) VALUES (1, :data)";
QSqlQuery sql(query);
sql.bindValue(":data", data);
sql.exec();
This failes and I get the following error:
ERROR: syntax error at or near "("
LINE 1: EXECUTE ('\\000\\000\\000\\000\\000\\000\\000\\000\\000\\0 0...
If I replace the :data with NULL, everything works fine.
Does anyone know how to insert binary dat into Postgres using QSqlDatabase and QSqlQuery.
Any reference to an online tutorial will also be greate, because I can't find one.
Thank you