I have a Postgres database with a BYTEA field.
I want to insert bytes into this fields.

I'm currently doing this:

Qt Code:
  1. QByteArray data = <get data>;
  2. QString query = "INSERT INTO images (id, bytes) VALUES (1, :data)";
  3. QSqlQuery sql(query);
  4. sql.bindValue(":data", data);
  5. sql.exec();
To copy to clipboard, switch view to plain text mode 

This failes and I get the following error:
Qt Code:
  1. ERROR: syntax error at or near "("
  2. LINE 1: EXECUTE ('\\000\\000\\000\\000\\000\\000\\000\\000\\000\\00...
To copy to clipboard, switch view to plain text mode 

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