Hello Srikanth,
If you use his method, bind_blob, no conversion is necessary. You
insert a JPG and you retrieve the JPG. I'd probably include the
filename to you can actually name the file if you want to later. I do
this all the time.
C
Monday, March 27, 2006, 5:59:24 PM, you wrote:
S> Boris,
S> Thanks. I have few more questions, though. How do I convert an image into
S> its hex equivalent? This is my situation: I would like to a) insert pictures
S> and their captions into a database table and, when needed fetch them and
S> display them in a webpage. I am going to use Python for inserting/fetching
S> the images and their captions. I am not sure, though, how an image can be
S> converted into its hex form, inserted, fetched and then reconverted into an
S> image. I am new to this process, so am not sure how this is done.
S> Thanks
S> Srikanth.
S> On 3/27/06, Boris Popov <[EMAIL PROTECTED]> wrote:
>>
>> You should bind the blob to the prepared insert statement,
>>
>> insert into first_table (picture_name, picture) values (?,?)
>>
>> Then sqlite3_bind_text() your name and sqlite3_bind_blob() your image
>> bytes
>> to the sqlite3_stmt that's the result of sqlite3_prepare().
>>
>> http://www.sqlite.org/capi3ref.html#sqlite3_prepare
>>
>> http://www.sqlite.org/capi3ref.html#sqlite3_bind_blob
>>
>> Or you could use X'53514697465' notation, where any blob can be expressed
>> as
>> a string in hex preceded by x or X.
>>
>> insert into first_table (picture_name, picture) values
>> ('dog',X'53514697465')
>>
>> Hope this helps,
>>
>> -Boris
>>
>> --
>> +1.604.689.0322
>> DeepCove Labs Ltd.
>> 4th floor 595 Howe Street
>> Vancouver, Canada V6C 2T5
>>
>> [EMAIL PROTECTED]
>>
>> CONFIDENTIALITY NOTICE
>>
>> This email is intended only for the persons named in the message
>> header. Unless otherwise indicated, it contains information that is
>> private and confidential. If you have received it in error, please
>> notify the sender and delete the entire message including any
>> attachments.
>>
>> Thank you.
>>
>> -Original Message-
>> From: Srikanth [mailto:[EMAIL PROTECTED]
>> Sent: Monday, March 27, 2006 2:15 PM
>> To: sqlite-users@sqlite.org
>> Subject: [sqlite] Inserting image files into a database table
>>
>> Hi,
>> Could someone give me the procedure for inserting images into a database
>> table?
>> E.g., say I created a table thus:
>> create table first_table( picture_name string, picture BLOB);
>>
>> How do I insert an image into the picture field?
>>
>> Thanks.
>> Srikanth.
>>
>>
>>
--
Best regards,
Tegmailto:[EMAIL PROTECTED]