On Fri, Nov 09, 2007 at 09:13:30AM +0200, Dan Pascu wrote:
> There is an issue in the sqlite backend regarding encoding/decoding. Below 
> is the relevant code from the __init__ method:
> 
> class SQLiteConnection(DBAPI):
>     [...]
>     def __init__(self, filename, autoCommit=1, **kw):
>         global sqlite
>         global using_sqlite2
>         if sqlite is None:
>             try:
>                 import sqlite3 as sqlite
>                 using_sqlite2 = True
>             except ImportError:
>                 try:
>                     from pysqlite2 import dbapi2 as sqlite
>                     using_sqlite2 = True
>                 except ImportError:
>                     import sqlite
>                     using_sqlite2 = False
>         self.module = sqlite
>         [...]
>         if using_sqlite2:
>             [...]
>             try:
>                 from sqlite import encode, decode
>             except ImportError:
>                 import base64
>                 sqlite.encode = base64.encodestring
>                 sqlite.decode = base64.decodestring
>             else:
>                 sqlite.encode = encode
>                 sqlite.decode = decode
> 
> Now if I have pysqlite2 installed it will be preferred over sqlite. 
> However the issue is that if I also have sqlite installed it will import 
> the encode/decode functions from there, while if I don't it will use 
> base64 encoding. 
> 
> I was recently hit by this as I has both installed and I was using a 
> sqlite3 database with PickleCol. Later I removed sqlite and suddenly my 
> database stopped working and gave errors on the pickle columns as the 
> encoder/decoder changed.
> 
> IMO if we use pysqlite2 or sqlite3 we shouldn't import encoders/decoders 
> from the old sqlite module, but instead use base64 always.

   Fixed in the revisions 3158-3161 (0.7, 0.8, 0.9 and the trunk).

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to