On 27/11/2007, Oleg Broytmann <[EMAIL PROTECTED]> wrote: > On Tue, Nov 27, 2007 at 07:16:16PM +0300, Oleg Broytmann wrote: > > On Tue, Nov 27, 2007 at 06:08:31PM +0200, Dan Pascu wrote: > > > So I think we should: > > > 1. get rid of the try/except > > Sorry, sent that to fast. > > > The point taken. Thank you! > > But... > > > > 2. only use the connection encoding to encode strings / string values > > > 3. use latin1 to encode/decode blobs that ensures that they are sent > > > unmodified to the db > > Alas, the code in question is in MySQLConnection, long past all > converters had worked. The connection got a query string. All connection > classes just pass the string down to their DB API drivers, but MySQLdb > requires (?) unicode so MySQLConnection converts the query string to > unicode. There is no way to distinguish integers, strings, unicode or BLOBs
As I read the docs, you are *allowed* to use unicode in queried, not required. If you use a string, it is assumed to be in the specified "charset" of the connection. The "use_unicode" parameter determines if one likes to get the *results* in unicode or string form back: http://mysql-python.sourceforge.net/MySQLdb.html use_unicode If True, CHAR and VARCHAR and TEXT columns are returned as Unicode strings, using the configured character set. It is best to set the default encoding in the server configuration, or client configuration (read with read_default_file). If you change the character set after connecting (MySQL-4.1 and later), you'll need to put the correct character set name in connection.charset. If False, text-like columns are returned as normal strings, but you can always write Unicode strings. This must be a keyword parameter. charset If present, the connection character set will be changed to this character set, if they are not equal. Support for changing the character set requires MySQL-4.1 and later server; if the server is too old, UnsupportedError will be raised. This option implies use_unicode=True, but you can override this with use_unicode=False, though you probably shouldn't. If not present, the default character set is used. This must be a keyword parameter. ------------------------------------------------------------------------- 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