The solution of MySQL Chinese garbled in SAE Python

Source: Internet
Author: User

At first I used:

Db=mysqldb.connect (db=sae.const.mysql_db,user=sae.const.mysql_user,passwd=sae.const.mysql_pass,host= Sae.const.mysql_host,port=int (Sae.const.MYSQL_PORT))

Database encoding and Python code are set to UTF8, in the phpMyAdmin to add Chinese records, in the page query display is garbled, I can not find any search on the Internet solution. Finally, we found that adding the charset parameter to the database when you connect to it is UTF8.

Db=mysqldb.connect (db=sae.const.mysql_db,user=sae.const.mysql_user,passwd=sae.const.mysql_pass,host= Sae.const.mysql_host,port=int (Sae.const.MYSQL_PORT), charset= ' UTF8 ')


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.