Am Freitag, 27. Juni 2008 01:20 schrieb Michael Bayer:
> first of all, the stack trace suggests you have not set the "encoding"
> parameter on create_engine() as it's still using UTF-8.
>
> If you mean that a single database column may have different encodings
> in different rows, you want to do your own encoding/decoding with
> "encoding errors" set to something liberal like "ignore". You also
> need to use your own custom type, as below:
>
> from sqlalchemy import types
> class MyEncodedType(types.TypeDecorator):
> impl = String
>
> def process_bind_param(self, value, dialect):
> assert isinstance(value, unicode)
> return value.encode('latin-1')
>
> def process_result_value(self, value, dialect):
> return value.decode('latin-1', 'ignore')
>
> then use MyEncodedType() as the type for all your columns which
> contain random encoding. No convert_unicode setting should be used
> on your engine as this type replaces that usage.
Perfect, that works, thanks!
Best Regards,
Hermann
--
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---