As far as I know all databases/access libraries have support for preparing statements and binding variables (e.g. PostgreSQL, ODBC, MySQL, etc.). The Python DB-API seems to imply that database libraries should be implemented using bound variables internally, yet the two I've checked does not..?
MySQLdb uses string inerpolation internally (from the implementation of cursor.execute(..)):
query = query % tuple([db.literal(item) for item in args])
and the _mysql.c implementation uses:
r = mysql_real_query(&(self->connection), query, len);
instead of the mysql_stmt_* functions.
In the psycopg2 library all execute paths seem to end up in _psyco_curs_execute, which calls _psyco_curs_merge_query_args, which merges "together a query string and its arguments." (cf. code).
Bound parameters are supposed to be both faster and more secure, so why do these libraries do string formatting instead? Since most queries will be unique, the query/statement caches will be of little use, should I dramatically reduce their sizes (to prevent the cache-maintenance overhead)?