SQLite User Forum

BLOB and Lazarus
Login

BLOB and Lazarus

(1) By anonymous on 2023-03-17 15:21:03 [link] [source]

Hello,

I have written a program in Lazarus Pascal that registers my book collection. I made the underlying database with Sqlite; everything works fine and communication with my Sqlite tables works fine. When I save a cover image of a book in my program, it is neatly saved in my program. But when I look in my sqlite file with Sqlitebrowser I see that the field is filled with a BLOB (that's good) but it doesn't show my actual image at the option "Image" and it shows a lot of text at the option "Binary ".

If I load an image in my BLOB field via Sqlitebrowser, the image is seen in the "Image" option, and also in my own written program.

In summary: Loading and saving image via my program displays the image in my program, but not in Sqlitebrowser (in the field there is a BLOB message). Conversely, loading and saving an image via Sqlitebrowser and viewing it in my program and in Sqlitebrowser works well.

Who is to blame? Lazarus, Sqlitebrowser or SQLite. In other words: Is this a Sqlite problem?

I hope you can help me.

(2) By Rado (antlor) on 2023-03-17 15:39:34 in reply to 1 [link] [source]

Hi,

I do not use Sqlitebrowser but I use SQLite in many Delphi projects. SQLite is definitely not to blame also Lazarus. When you store data in blob field it can have any data and only your program knows what is in. But programs like Sqlitebrowser can have option how to present data in blob field. You should ask author for Sqlitebrowser if that option exists if you can't find it your self. For my use I have such program like Sqlitebrowser (I have wrote in delphi) and I did put that option to see for example image or text. It is Blob edit properties I can choose picture, memo, ole, auto. For picture I can choose jpeg, bmp, meta, ico, png.

Best Regards

(3) By Donal Fellows (dkfellows) on 2023-03-17 15:44:28 in reply to 1 [link] [source]

For some program to render a BLOB as an image, it has to detect that the binary data indeed is an image in a format that the program supports. There are a very large number of image formats! And not all BLOBs are image data; I've got binary simulation traces in mine, and they need a lot of processing to turn into plots.

It sounds like some of the programs you are using are saving image data in a format that all the programs in that group you care about understand, and other programs are using formats that are less widely understood. SQLite's correctly holding onto the data without interpreting it, but you can't render data as an image without applying an interpretation.

(4) By anonymous on 2023-03-17 16:31:10 in reply to 3 [source]

Rado and Donal Fellows thanks for your reply. I did a test with Sqlitestudio with the same problem. So it seems that the translation from Sqlite to my Lazarus program goes well, but from Lazarus to Sqlite does not work. I'll take a closer look at my program and see how far I get. If I find the solution, I'll share it here

Thanks again for your contribution.

(5) By Keith Medcalf (kmedcalf) on 2023-03-17 16:57:35 in reply to 4 [link] [source]

THere is no translation. Your program is storing a BLOB that it knows how to interpret. Other programs that are not your program do not know how to interpret that blob.

There is nothing wrong with anything anywhere other than your expectations.

(6) By anonymous on 2023-03-17 19:56:13 in reply to 5 [link] [source]

Okay, I understand and will accept this fact.

Thank you