> I'm new to SQLite, coming from an Access/VB background. Having moved over to Linux I'm now developing an application using Gambas. One of the requirements is to store a scanned document (PDF) in a record as a blob, along with its metadata. I've no problem selecting the document, but I'm struggling to work out how to assign it to the blob field. Does anybody have any tips or, possibly, the URL of a site that could assist?
A blob stores a sequence of bytes. The bytes can represent anything you like. So you could, for example, read in a PDF file and store the bytes of that file in a BLOB. You'll probably want to store the file's name in another column, too.
Simon.
There are two ways. If you have the whole document in a single memory buffer, then just prepare a statement like
insert into mytable(document) values (?);
use sqlite3_bind_blob to bind your memory buffer as a parameter, and run the statement.
Alternatively, you can use sqlite3_blob_open, sqlite3_blob_write et al. This way you don't need to have all the data in memory at once (useful for very large blobs), but you still have to know the size up front.
--
Igor Tandetnik