Jay Calaus wrote:

Now I'm investigating using pysqlite for some quick
and dirty jobs and I'm trying to understand if there
is a need to prepare the statements once, then bind
and insert for every record, the same way I did it in
C.

Your example above seems to do all of these in one
shot.  Do you know what happens behind the scenes with
your example?  Is there an implicit "prepare" that
happens once and then a bind/insert everytime the
statement is encountered?
Jay,

Yes, there is an implicit prepare (in reality there has to be in order to get sqlite to execute any SQL). I'm not 100% sure about what goes on behind the scenes with pysqlite since I haven't looked at the source (to be sure you could since it is open source), but this is my understanding. Internally pysqlite prepares and caches SQL statements the first time it sees them. If the same SQL statement is repeated, it re-uses the cached copy. It will bind new argument values, if present, to the cached prepared statement before executing it. I believe it binds values using the the python type of the arguments (i.e. a float is bound using sqlite3_bind_double).

If you are doing a series of inserts it is still important to ensure they are done inside a transaction to get good performance.

HTH
Dennis Cote




-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to