-1

I'm running a pretty basic script that is querying a MySQL table, but I'm running into an error that I can't find online. I see a lot of charmap/codec related issues online, but all have to do with reading text or data.

This error is happening when I attempt a MySQL SELECT query, or at least I think it is.

Does anyone know why Python would error on this?

enter image description here

My code reads like this:

enter image description here

Line 188 is where the error occurs.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
DobotJr
  • 3,929
  • 9
  • 36
  • 49
  • 1
    Please avoid posting images (or worse, links to images) of code or errors. Anything text-based (code and errors) should be posted as text directly in the question itself and formatted properly as a [mre]. You can get more [formatting help here](https://stackoverflow.com/help/formatting). You can also read about [why you shouldn't post images/links of code](//meta.stackoverflow.com/q/285551). – Tomerikoo Aug 12 '21 at 11:59

2 Answers2

1

Please look at the following answer: Encoding Issue - MySQL

Adding the extra parameters while creating connection should resolve your issue.

con = mdb.connect('loclhost', 'root', '', 'mydb', use_unicode=True, charset='utf8')

Thanks.

0

alt column contains OSC control character (0x9d). Seems to be a data problem. You could try replacing the character to verify that's the issue but the long term solution should be to not allow those character in a string, convert them to html entities, or specify a connection character set.

SELECT id, REPLACE(alt, UNHEX('9D'), '') ...

See also this.

LMC
  • 10,453
  • 2
  • 27
  • 52