So I tried setting the convert_unicode=True, but I am still getting
the same error.

Then I tried setting connect_args={'client_encoding':'latin1'} as an
argument in the create_engine, but that returned:
DBAPIError: (TypeError) 'client_encoding' is an invalid keyword
argument for this function None None

One thing I messed around with was doing the following after creating
my engine:
engine.connect().connection.set_client_encoding('latin1')

Can you explain what is happening there and if there is a way to do
that on all connections across the board for that engine?

thanks a lot,
Matt

On Apr 4, 10:40 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Apr 4, 2008, at 11:07 AM, mg wrote:
>
>
>
> > I have a postgres db that has content currently encoded as latin1.
> > When I try to query from the db I get the following error:
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xa9 in position
> > 0: ordinal not in range(128)
>
> > in my create_engine call I have encoding=latin parameter set. What am
> > I missing?
>
> > I know that when I have worked with psycopg2 directly before i have
> > been able to use the set_client_encoding('latin1') and that has worked
> > fine.
>
> well a basic thing is, SQLA interprets strings as plain bytestrings
> unless you use the Unicode datatype, or you set the
> "convert_unicode=True" on your engine to do it across the board.  The
> "encoding" parameter doesn't get used otherwise.  If you haven't done
> either of those, that's a place to start.
>
> I'm not sure if psycopg2 has the "client_encoding" parameter available
> at the connection level as a keyword argument to connect(). If it did,
> you could also set that up when you do create_engine() using the
> connect_args dictionary.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to