Hello Dennis,

Friday, February 17, 2006, 11:23:02 AM, you wrote:

DC> Pavan Savoy wrote:

>>Hi,
>>                 sqlite3_exec is a wrapper function for sqlite3_prepare /
>>step, but which one of these is faster, I mean in terms of execution.
>>sqlite3_exec should still call a callback function and do all the string
>>handling !!
>>
>>
>>Also how do I use sqlite3_exec along with BLOB, I am currently using
>>sqlite3_bind_blob after an prepare and then I do step, but for _exec how
>>do I do it ??
>>
>>
>>Help this newbie..
>>
>>
>>Thank you
>>  
>>
DC> Pavan,

DC> Used correctly sqlite_prepare/step/finalize will be faster than 
DC> sqlite_exec, since sqlite_exec is implemented using 
DC> sqlite_prepare/step/finalize. The sqlite_exec method will have as much,
DC> or more, overhead as your own calls to sqlite_prepare/step/finalize.

DC> That being said, sqlite_exec is often more convenient for non query SQL
DC> statements.

DC> Finally, you can't use BLOB data directly with sqlite_exec. More 
DC> particularly, you can't retrieve data that may contain zero bytes using
DC> sqlite_exec. This is because sqlite_exec uses zero terminated C strings
DC> to return its results.

DC> You can use the quote() function to convert your BLOB data into a string
DC> that can be returned from sqlite_exec. Similarly, you must format any
DC> BLOB data you want to insert using sqlite_exec as a literal hex string.

DC> It is generally easier to use the prepare/step/finalize functions and
DC> the sqlite_bind_blob and sqlite_column_blob/sqlite_column_bytes  
DC> functions to deal with binary data.

DC> HTH
DC> Dennis Cote

Switching to prepare/step has HUGELY reduced the hassle of adding data
to a DB. It's the only way I'll do it any more. The problems I was
running into was the whole formatting of the data before insertion
thing. I was constantly running into cases where what I wanted to
insert required escaping so as to not run afoul of the SQL naming
convention and as you point out, blobs were mostly unusable without
encoding.


-- 
Best regards,
 Teg                            mailto:[EMAIL PROTECTED]

Reply via email to