Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect string value warning when calling stored procedure in python

I have a database that has a stored procedure that I call it in my python script.
until yesterday there were no problem with it.
but yesterday my database server had a problem and restored the database.
now I'm getting this warning from the same code:

Warning: Incorrect string value: '\xD9\x88\xD8\xB2\xDB\x8C...' for column 'title' at row 1

I checked some encodings in DB :
In INFORMATION_SCHEMA.COLUMNS:

+--------------+--------------------+
| COLUMN_NAME  | CHARACTER_SET_NAME |
+--------------+--------------------+
| title        | utf8               |
+--------------+--------------------+

Database collation: latin1_swedish_ci
Table collation: utf8_general_ci
Column collation: utf8_general_ci
Server charset: UTF-8 Unicode (utf8)
(All are same as before!!)

and I'm connecting using this:

self.con=mdb.connect(host=self.host, user=self.user, passwd=self.passwd, db=self.dbname,use_unicode=True, charset="utf8");

and variable title is unicode.

I tried:

  • Altering table and re setting utf8_general_ci for title column
  • calling SET NAMES utf8 before calling procedure.
  • Removing and re-creating stored procedure

None worked!!! :-(


I executed an insert query on a temporary table with Unicode content and it worked without that warning!!!


What is the problem?
how can I fix this?

Thanks

like image 858
Ariyan Avatar asked Dec 27 '22 09:12

Ariyan


1 Answers

Problem solved!
I added CHARACTER SET utf8 to my stored procedure's VARCHAR arguments and problem solved:

..., IN `title` VARCHAR(255) CHARSET utf8,...

But yet I wonder why before restoring DB there was no problem !!!???

like image 96
Ariyan Avatar answered Dec 28 '22 23:12

Ariyan