On 18 Jan 2012, at 12:30pm, Petr Lázňovský wrote:

>>> have windows batch working with sqlite, may I insert image into database 
>>> and than read this images from?
> 
>> Convert your image into a BLOB and store it as a BLOB.  BLOBs are just runs 
>> of bytes -- you can store anything you want as a BLOB.
> 
> What you mean by "Convert image into a BLOB" is there some kind of SW to do 
> this? Does SQLite offer some way to do this? Sorry for dumb question, but I 
> googling about this some time with no luck..

If you don't already know how to use your programming language to store 
integers and strings in a SQLite database, then learn that first.  Once you 
have software which can do that, read on:

An image (assuming you mean a file like a .jpeg or .png file) is just a long 
run of bytes.  You can store a long run of bytes in a SQLite database as data 
of type 'BLOB'.  This isn't a string, or a number, or a date, it's just a long 
run of bytes which is stored exactly as supplied with no interpretation.

So in your software, open the image file and read the contents of the file into 
memory.  Then use the SQLite library routine to create a new row, and bind that 
piece of memory to a BLOB.  When you want to retrieve that data, read the BLOB 
back out of the database.  Then if you want to make an image file of it you can 
do that.  If you want to display the image on the screen without making a file 
of it, you can do that instead if your programming language gives you way to do 
it.

The exact routines to use depends on the language your software is written in: 
C, Python, PHP, whatever.  That's all down to your personal programming choice. 
 But all the commonly-used interfaces to SQLite have the ability to handle 
BLOBs.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to