[New-bugs-announce] [issue12993] prepared statements in sqlite3 module
Mayur & Angela Patel-Lam
report at bugs.python.org
Fri Sep 16 14:34:19 CEST 2011
New submission from Mayur & Angela Patel-Lam <patel.lam.family at gmail.com>:
The sqlite3 module is wonderful, but the one advantage that C/C++ coders have using that system is the ability to use precompiled/prepared SQL statements. Some SQL databases like Postgresql allow you to precompile statements using special SQL statements (e.g. PREPARE), so there is no need to change the python DBI for those database systems. But unfortunately, sqlite3 only offers a C/C++ function, which returns a handle to the prepared statement. I have sought a way to call this from the python DBI, but I simply don't think it's exposed.
Since my application interleaves several SQL commands, depending on the results of the last iteration, I can't immediately use executemany() to obtain maximum performance on my code. Precompiled statements offer me the best opportunity to optimize. I can prepare the 2 or 3 most expensive queries in my loop and call them in whatever order I need. There are some estimates that prepared statements can accelerate complex queries by an order of magnitude, as the parser and optimizers don't need to come into play for every call.
Would you consider an extension to the sqlite3 DBI to expose prepared statements? Thanks.
components: Library (Lib)
title: prepared statements in sqlite3 module
type: feature request
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce