[Yum-devel] [PATCH] Support newer pysqlite for yum proper
tim at rasmil.dk
Fri Oct 27 13:07:26 UTC 2006
Jeremy Katz wrote:
> And here's the biggest chunk needed for python2.5 and/or the newer
> pysqlite support.
> The big change with the newer version of pysqlite is that it actually
> follows the python DB-API. This means that (by default) rows are
> just returned as tuples. Luckily, it's easy to make it so that we can
> get back dict-like rows. So half of the changes here are going from
> something like row.name -> row["name"].
> The other (and more annoying) change is that pysqlite now uses qmark
> instead of pyformat for escaping in queries. Which means that to
> support both we either have to
> a) do a conversion on the fly
> b) maintain two copies of the code
> Since b seems like it would be a maintenance nitemare, I've gone for a.
> First, I converted everything to qmark style (this uses ? instead of %s
> for parameters) and then have imported a chunk of Wichert Akkerman's
> python-dhm so that we can convert on the fly to pyformat style escaping.
> While ugly, it seems to work and I've done some very basic smoke testing
> with both python 2.5 and python 2.4 and things seem to be fine with
> both. More testing is definitely needed, though.
> Other thoughts or opinions on ways to go about this? I'm more than open
> to listening because I really don't like this as it stands :-/
>  http://www.python.org/dev/peps/pep-0249/
I agree with your choice to to conversion on the fly, i dont think it is
so ugly, the code is as easy to read as it was before.
The only other way is can think of is to make a custom Conection &
Cursor class there inherit from the original sqlite classes
here is some psudo code to show what i mean.
import sqlite3 as sqlite
SQLITE3 = True
SQLITE3 = False
import sqlitecust as sqlite
More information about the Yum-devel