[odb-users] MySQL BLOB Support

Boris Kolpackov boris at codesynthesis.com
Wed Nov 2 09:50:02 EDT 2011


Hi Pascal,

Pascal Stoll <past0004 at stud.fh-kl.de> writes:

> i would like to know if it possible to store medium oder large blobs in 
> mysql? By now i can only store normal blobs (64kb). Did i do something 
> wrong?

By default QByteArray (which I assume is what you are using) is mapped to
the MySQL BLOB type. In MySQL, BLOB can store maximum 64Kb. If you want
to store more, you will need to map it to either MEDIUMBLOB or LONGBLOB.
You can do it on the per-type basis:

#pragma db value(QByteArray) type("LONGBLOB")

class object
{
  ...

  QByteArray data_; // Mapped to LONGBLOB.
};

Or on the per-member basis:

class object
{
  ...

  #pragma db type("MEDIUMBLOB")
  QByteArray data_;
};

You may also want to check other limitations on the BLOB sizes at the
bottom of this page from the MySQL documentation:

http://dev.mysql.com/doc/refman/5.1/en/blob.html

Boris



More information about the odb-users mailing list