On Jul 25, 2008, at 10:35 AM, Sherief N. Farouk wrote: > I want to use blobs to store binary objects in the database, but > I'm having > a hard time understanding how they work. First of all, I don't see > a way to > set a blob's size, and sqlite3_blob_write doesn't increase the size > of the > blob, which is putting me in a weird catch-22 situation. > > What's the best solution for storing a bunch of binary objects, > given the > two alternatives: They may be immutable (write once, read many), or > mutable > (write many, possibly overwriting regions or appending, write many)?
You can work with blobs without using the sqlite3_blob_XXX() APIs. Insert blobs by binding them with sqlite3_bind_blob(), retrieve them using sqlite3_column_blob(). Sometimes it is better to use the sqlite3_blob_XXX() APIs because they allow sqlite to work with large blobs without creating a copy of the blob in memory. To create a large zeroed blob in the database, use either sqlite3_bind_zeroblob() or the "zeroblob" SQL function. Then populate it using sqlite3_blob_XXX() after it has been inserted. Dan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users