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
Pavan,
Used correctly sqlite_prepare/step/finalize will be faster than
sqlite_exec, since sqlite_exec is implemented using
sqlite_prepare/step/finalize. The sqlite_exec method will have as much,
or more, overhead as your own calls to sqlite_prepare/step/finalize.
That being said, sqlite_exec is often more convenient for non query SQL
statements.
Finally, you can't use BLOB data directly with sqlite_exec. More
particularly, you can't retrieve data that may contain zero bytes using
sqlite_exec. This is because sqlite_exec uses zero terminated C strings
to return its results.
You can use the quote() function to convert your BLOB data into a string
that can be returned from sqlite_exec. Similarly, you must format any
BLOB data you want to insert using sqlite_exec as a literal hex string.
It is generally easier to use the prepare/step/finalize functions and
the sqlite_bind_blob and sqlite_column_blob/sqlite_column_bytes
functions to deal with binary data.
HTH
Dennis Cote