PDA

View Full Version : Sqlite3 and Blobs




binjaja
Nov 13, 2008, 10:01 PM
I am having trouble learning how insert blobs into SQLite for the iphone. Is there a way to insert a blob into sqlite3 from the command line? I know it was possible with sql using
INSERT INTO temponly(name , pic) values( 'velan',
load_file('e:/mysql/images/Click.gif')) ;



but I don't think load_file is supported on sqlite.

Also, I need to insert the blobs from my iphone app. I saw a C program called eatblob.c which goes through the following just to INSERT a blob into sqlite

1. read the jpeg image file into memory , doing appropriate malloc based on size

2. prepare an sqlite statement with ? values
3. bind the malloc'd memory to the ?
4. execute an sqlite step

etc. etc. etc....

This is quite a bit of work just to do an INSERT ???

The reason I'm doing this is my iphone app has a lot of tiny (20x20) images that get downloaded to the phone periodically from the server. Plus, there are a number of images that come loaded with the application. I was going to save all of these in SQLite. So, I need the command line tool to load up the initial images that come with the app, then I need code to download the images from the server and load them into the database. Of course, reading them out is necessary!




Please help if you can!? Its late..and I'm blurry eyed from googling SQLIte3 blobs...



dipaliP
Nov 25, 2008, 03:24 AM
You can just save the name of image. And save image in Documents folder (by converting it into NSData type).
So you can get the image according to name saved in table.