[Monetdb-developers] encoding of strings returned by Python client

Mark Bucciarelli mkbucc at gmail.com
Tue Dec 22 13:43:25 CET 2009


On Tue, Dec 22, 2009 at 5:30 AM, Gijs Molenaar <gijs.molenaar at cwi.nl> wrote:
>
> Do you know the behavior of other db API's?
>

MSQLdb has a use_encoding keyword.

The PostgreSql Django adapter had a set_client_encoding()
method on the connection object.

The native SQLite3 Python module just returns Unicode.

>
> How big is the problem to do a manual
> conversion to unicode in your wrapper?
>

Painful--I couldn't find a good place to hook
in the code.

>
> The problem is that there isn't a real standard
> way of doing this, at least not defined by the
> python db API 2.0.
>

Yup, the PEP is encoding agnostic.

I though the path you started down was a good
idea; pass a use_unicode keyword to the connection
__init__().

Then if use_unicode = True, just decode("utf8") the
string in __strip(), otherwise leave code as is.

m




More information about the developers-list mailing list