473,473 Members | 1,959 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MySQL hardcoding?

I've got this error (see the path in last line)

db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos')
File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 74, in Connect
return Connection(*args, **kwargs)
File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 198, in __init__
self.set_character_set(charset)
File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 277, in set_character_set
super(Connection, self).set_character_set(charset)
OperationalError: (2019, "Can't initialize character set Windows-1251 (path: C:\\mysql\\\\share\\charsets\\)")

The truth of the matter is, MySQL is not installed in that path, but into Program Files.
I don't know where the hardcoding is, but it is certainly somewhere. Except MySQL is reporting a wrong installation path.
I haven't found any other topic in the list about this problem.

I'm using Python 2.4 and latest MySQLdb. Have anyone heard of this issue and how to fix it?

Thanks a lot.
Jun 27 '08 #1
3 3017
ma********@googlemail.com wrote:
I've got this error (see the path in last line)

db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos')
Can't help with the answer to your question, but this may stave off yet
another question:

The empirical evidence from other recent postings is that you are
mucking about with Spanish-language newspaper "articulos" on the web ...
so why charset = "Windows-1251", which is Cyrillic (i.e. Russian etc)??
Perhaps you mean 1252 which is Microsoft's latin1 with extras.

HTH,
John
Jun 27 '08 #2
On Thu, 17 Apr 2008 22:00:21 GMT
John Machin <sj******@lexicon.netwrote:
The empirical evidence from other recent postings is that you are
mucking about with Spanish-language newspaper "articulos" on the web ...
so why charset = "Windows-1251", which is Cyrillic (i.e. Russian etc)??
Perhaps you mean 1252 which is Microsoft's latin1 with extras.

HTH,
John
--
http://mail.python.org/mailman/listinfo/python-list
Yes John, thanks. The only problem is MySQL doesn't include a cp1252 or Windows-1252 or ansi. I'm trying to find my way with different approaches.
But there is certainly a problem if an application goes to the wrong folder to get data as MySQL seems to be doing.

Thanks.
Jun 27 '08 #3
ma********@googlemail.com wrote:
I've got this error (see the path in last line)

db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos')
File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 74, in Connect
return Connection(*args, **kwargs)
File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 198, in __init__
self.set_character_set(charset)
File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 277, in set_character_set
super(Connection, self).set_character_set(charset)
OperationalError: (2019, "Can't initialize character set Windows-1251 (path: C:\\mysql\\\\share\\charsets\\)")

The truth of the matter is, MySQL is not installed in that path, but into Program Files.
I don't know where the hardcoding is, but it is certainly somewhere. Except MySQL is reporting a wrong installation path.
I haven't found any other topic in the list about this problem.

I'm using Python 2.4 and latest MySQLdb. Have anyone heard of this issue and how to fix it?

Thanks a lot.
Well, for one thing, MySQL doesn't have a character set called
"Windows-1251", which is an obsolete Cyrillic variant of Windows.
See the list of MySQL character sets at:

"http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html"

MySQL does have "cp1251", which is apparently the same thing.

Be aware that in Python, there are really only two character
sets - ASCII and Unicode. The "upper code page" thing is deprecated,
and you can't do some string operations on characters with values 128.
It's best to convert input to Unicode, run everything in Python in
Unicode, send to the database in "utf8", and store your data in "utf8".

You have "use_unicode" set to True. If you're going to run
the MySQL connection in Unicode, you should use "utf8" talking to the
database, and Unicode strings in Python. Otherwise, you have to
understand very clearly exactly how both Python and MySQL handle
character sets, and how this changes in Python 2.4, 2.5, and 3.x.

John Nagle
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mikey | last post by:
Hi all, I'm having great problems trying to install the latest MySQl RPM package onto my Red Hat Linux OS. There is already MySQL v 3.0 pre-installed with the RH Linux distribution disk but I...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
by: AngryGerbil | last post by:
hey, How do I acquire MethodInfo WITHOUT hardcoding method name as a string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod", xxx) is making me want to drive an ice pick into my eye! I...
8
by: AngryGerbil | last post by:
hey, How do I acquire MethodInfo WITHOUT hardcoding method name as a string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod", xxx) is making me want to drive an ice pick into my eye! I...
3
by: Angelos | last post by:
Hello again, I have this dynamic menu and I want to change the order of the menu items... I added a column in the database wich has an integer value for ordering the menuitems. But the only way...
2
by: trihanhcie | last post by:
I m currently working on a Unix server with a fedora 3 as an os My current version of mysql is 3.23.58. I'd like to upgrade the version to 5.0.18. After downloading from MYSQL.COM the package on...
1
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: ...
3
by: menzies | last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a...
0
by: Gabriel Genellina | last post by:
En Thu, 17 Apr 2008 15:41:49 -0300, <marexposed@googlemail.comescribió: Looks like a configuration problem in MySQL itself, unrelated to Python. See the my.ini file in MySQL installation...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.