sqlite utf8 encoding error

Manlio Perillo NOmanlio_perilloSPAM at libero.it
Sat Nov 19 03:55:50 EST 2005


On 18 Nov 2005 09:09:24 -0800, "Greg Miller" <et1ssgmiller at gmail.com>
wrote:

>Thank you for all your suggestions.  I ended up casting the string to
>unicode prior to inserting into the database.  
>

Don't do it by hand if it can be done by an automated system.

Try with:

from pysqlite2 import dbapi2 as sqlite

def adapt_str(s):
    # if you have declared this encoding at begin of the module
    return s.decode("iso-8859-1") 

sqlite.register_adapter(str, adapt_str)


Read pysqlite documentation for more informations:
http://initd.org/pub/software/pysqlite/doc/usage-guide.html



Regards  Manlio Perillo



More information about the Python-list mailing list