It is currently Sat Jul 06, 2024 9:00 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: No, the data is good.
PostPosted: Wed Apr 10, 2013 4:09 pm  (#21) 
Offline
GimpChat Member

Joined: Mar 15, 2013
Posts: 36
ofnuts wrote:
1) I'm afraid that the '?' are just question marks as returned by MySQL so there is nothing to do about it in the Python code. Either the data in MySQL is still good(*) and it may be a MySQL configuration or request setup problem, or it is already corrupted and its hopeless.

....

The data is good in MySQL. I have two important tools for browsing my MySQL databases. There is MySQL Workbench and MySQL Query Browser. It is interesting to note that MySQL Workbench displays the data fine as do my other applications. But MySQL Query Browser has the exact same display errors.


Top
 Post subject: Re: No, the data is good.
PostPosted: Wed Apr 10, 2013 5:34 pm  (#22) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
Grafx wrote:
ofnuts wrote:
1) I'm afraid that the '?' are just question marks as returned by MySQL so there is nothing to do about it in the Python code. Either the data in MySQL is still good(*) and it may be a MySQL configuration or request setup problem, or it is already corrupted and its hopeless.

....

The data is good in MySQL. I have two important tools for browsing my MySQL databases. There is MySQL Workbench and MySQL Query Browser. It is interesting to note that MySQL Workbench displays the data fine as do my other applications. But MySQL Query Browser has the exact same display errors.

Then at that point you'll get more help from a MySQL forum :)

_________________
Image


Top
 Post subject: Re: No, the data is good.
PostPosted: Wed Apr 10, 2013 5:54 pm  (#23) 
Offline
GimpChat Member

Joined: Mar 15, 2013
Posts: 36
ofnuts wrote:
Then at that point you'll get more help from a MySQL forum :)


Yes, that's my next stop, I guess. I've also tried Stackoverflow and a Python forum. Thanks to you and all who posted suggestions. This issue has been a real pain across no less than four or five different technical settings and now this. Bummer.

I'll report back as soon as I find a solution.

Meanwhile anyone else should feel free to add suggestions. Any and all tips or clues would be appreciated.


Top
 Post subject: Fixed it.
PostPosted: Thu Apr 11, 2013 12:28 pm  (#24) 
Offline
GimpChat Member

Joined: Mar 15, 2013
Posts: 36
Well, up to now I have been programming in Perl and had to encounter all the same problems in Perl. I went back to see what kind of things I did to confront the problem there and it turns out that the solution was to change a setting in the database, the programming language had nothing to do with it.

So in order to get the character set corrected, before you make your query in Python, you have to tell the database connection "SET NAMES 'utf8'". So a sample Python code might be (this is a simple script, NOT a plug-in) ...

#!/usr/bin/python

import MySQLdb

db = MySQLdb.connect("Your_MySQL_Host","Your_MySQL_User","Your_MySQL_User_Password","Your_Database" )
cursor = db.cursor()

cursor.execute("SET NAMES 'utf8'")

cursor.execute("SELECT Your_Field FROM Your_Table")
results = cursor.fetchall()

for row in results:
    trial_nam = row[0]
    print trial_nam

db.close()


That did it. Problem Solved.

There is an excellent tutorial on using MySQL with Python here,

http://www.tutorialspoint.com/python/python_database_access.htm


Top
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts use in python of plug-in lighting

4

No new posts Attachment(s) GIMP Python-Fu Plug-in template

4

No new posts GIMP 2.10 doesn't install my python plug-ins

1

No new posts Plug-in crashes after OS upgrade: python version mismatch? maybe?

4

No new posts Convert GIMP plugin from Python 2 to Python 3

4



* Login  



Powered by phpBB3 © phpBB Group