Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-05

Inserting images in mysql records

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hugues Moisy

Hi all,

I'm trying to insert gif file content into a blob field in a mysql database. Insertion process works, but the size of the data inserted is cut to 64 Kbytes, so the images are cut and impossible to read (crash), except those that are less than 64KB.

my function is this :

       conn := getConnection(_TypeConnection);
       query.DataBase := conn;
       query.UsePrimaryKeyAsKey:=false;
       query.SQL.clear;
       query.SQL.Add('update volumepage set page_image = :image,
image_filename = :imgname where volume_id = :vol and page_index = :page');
       query.Params.ParamByName('vol').Value:=pVolumeId;
       query.Params.ParamByName('page').Value:=pPageIndex;
       query.Params.ParamByName('image').LoadFromFile(pFileName,ftBlob);
       query.Params.ParamByName('imgname').Value:=pFileName;
       query.ExecSQL;

could somebody explain me the origin of the problem : is it a problem in the database, or in the LoadFromFile ?

Thanks in advance. Hugues

Utilisant le logiciel de courrier r?volutionnaire d'Opera : http://www.opera.com/mail/

Reply by email

Unknown author
to Hugues Moisy
Hugues Moisy wrote 25 lines
Hi all, I'm trying to insert gif file content into a blob field in a mysql database. Insertion process works, but the size of the data inserted is cut to 64 Kbytes, so the images are cut and impossible to read (crash), except those that are less than 64KB. my function is this : conn := getConnection(_TypeConnection); query.DataBase := conn; query.UsePrimaryKeyAsKey:=false; query.SQL.clear; query.SQL.Add('update volumepage set page_image = :image, image_filename = :imgname where volume_id = :vol and page_index = :page'); query.Params.ParamByName('vol').Value:=pVolumeId; query.Params.ParamByName('page').Value:=pPageIndex; query.Params.ParamByName('image').LoadFromFile(pFileName,ftBlob); query.Params.ParamByName('imgname').Value:=pFileName; query.ExecSQL; could somebody explain me the origin of the problem : is it a problem in the database, or in the LoadFromFile ?

It depends on the type of field you created in the database. If it is a 'Text' field, then I think Mysql limits the content to 64k bytes.

sqldb by itself does not impose limits, as far as I know.

Michael.

Reply by email

Hugues Moisy
to Unknown author

Hi Michael,

Thank you for your answer.

No my field is declared as BLOB and not text. But after searching on web, I found that BLOB type in 64KB. I have to use MEDIUMBLOB and LONGBLOB instead.

Hope it'll be useful for anybody else.

Hugues

Le Fri, 04 May 2012 15:15:47 +0530, a ?crit:

Show quoted text 43 lines
On Fri, 4 May 2012, Hugues Moisy wrote: > Hi all, > > I'm trying to insert gif file content into a blob field in a mysql > database. Insertion process works, but the size of the data inserted is > cut to 64 Kbytes, so the images are cut and impossible to read (crash), > except those that are less than 64KB. > > my function is this : > > conn := getConnection(_TypeConnection); > query.DataBase := conn; > query.UsePrimaryKeyAsKey:=false; > > query.SQL.clear; > query.SQL.Add('update volumepage set page_image = :image, > image_filename = :imgname where volume_id = :vol and page_index = > :page'); > query.Params.ParamByName('vol').Value:=pVolumeId; > query.Params.ParamByName('page').Value:=pPageIndex; > query.Params.ParamByName('image').LoadFromFile(pFileName,ftBlob); > query.Params.ParamByName('imgname').Value:=pFileName; > > query.ExecSQL; > > could somebody explain me the origin of the problem : is it a problem > in the database, or in the LoadFromFile ? It depends on the type of field you created in the database. If it is a 'Text' field, then I think Mysql limits the content to 64k bytes. sqldb by itself does not impose limits, as far as I know. Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Utilisant le logiciel de courrier r?volutionnaire d'Opera : http://www.opera.com/mail/

Reply by email