On Fri, 2006-03-24 at 17:13 -0800, Lauren LaGarde wrote:
> I'm fairly new to Python and Trac. I've been studying the code in
> trunk/trac/db/sqlite_backend.py, and the execute function,
> particularly line 37, really makes no sense to me. Could somebody
> explain what exactly this code is doing?
>
> 35 def execute(self, sql, args=None):
> 36 if args:
> 37 sql = sql % (('?',) * len(args))
> 38 return self._rollback_on_error(sqlite.Cursor.execute, sql,
> 39 args or [])
The Python DB-API allows different formats for parameterized queries.
The queries in Trac use the "format" style like:
select * from ticket where id = %s
The method above converts it to the "qmark" style used by the pysqlite2
and runs the query:
select * from ticket where id = ?
--
Matthew Good <[EMAIL PROTECTED]>
_______________________________________________
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac