[sqlalchemy] Re: MySQL encoding problems

2008-07-25 Thread jason kirtland

Raoul Snyman wrote:
 Hi,
 
 I'm writing a Pylons app, connecting to an existing oldish database,
 and while connecting from my Mac desktop everything is fine, but when
 I connect from our dev server, I get the following error:
 
 LookupError: unknown encoding: latin1_swedish_ci
 
 I've done some Googling, found a couple of posts on here, as well as
 elsewhere, and I'm not sure what they're talking about in those posts
 (specifically, I don't see how they solved the problem).
 
 Desktop versions:
 Mac OS X 10.4
 Python 2.5
 SQLAlchemy: 0.5.0beta2
 MySQLdb: 1.2.2 final
 Pylons: 0.9.6.2
 
 Dev server versions:
 Linux Server: Gentoo 3.3.5.20050130-r1
 MySQL Server: 4.1.9-max-log
 Python: 2.4.4
 SQLAlchemy: 0.5.0beta2
 MySQLdb: 1.2.2 final
 Pylons: 0.9.6.2
 
 Unfortunately I can't change the db in any way, as this app is simply
 pulling a subsection of data out of an already existing system.
 
 Any ideas? Do you need more info? A stack trace?

LookupError is pretty general...  Would need to see a stack trace.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: MySQL encoding problems

2008-07-25 Thread Philip Semanchuk

On Jul 25, 2008, at 5:34 AM, Raoul Snyman wrote:

 I'm writing a Pylons app, connecting to an existing oldish database,
 and while connecting from my Mac desktop everything is fine, but when
 I connect from our dev server, I get the following error:

 LookupError: unknown encoding: latin1_swedish_ci

 I've done some Googling, found a couple of posts on here, as well as
 elsewhere, and I'm not sure what they're talking about in those posts
 (specifically, I don't see how they solved the problem).

Hi Raoul,
I'd guess that this error is coming from Python's codecs module,  
probably indirectly from a call to unicode() with the encoding param  
set to 'latin1_swedish_ci'.

It looks like that's the default for MySQL installations:
http://dev.mysql.com/doc/refman/5.0/en/charset-we-sets.html

But Python's never heard of it:
http://docs.python.org/lib/standard-encodings.html

  import codecs
  codecs.lookup(latin1_swedish_ci)
Traceback (most recent call last):
   File stdin, line 1, in module
LookupError: unknown encoding: latin1_swedish_ci
 


So my guess is that SA is reading the encoding from the database and  
then trying to convert text fields to Unicode and getting the error  
above. Why this happens on one box and not another is mysterious. I'm  
also on a Mac and it knows nothing about latin1_swedish_ci, so I don't  
know why yours would be any different. Has your Mac Python perhaps  
been compiled with some MySQL-awareness? If you run this at the  
command line on your Mac, what does it report?

python -c import codecs; codecs.lookup('latin1_swedish_ci')


Cheers
Philip


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---