Flask_sqlalchemy garbled problem

Source: Internet
Author: User

In short,/etc/my.conf

The DEFAULT_CHARACTER_SET=UTF8 is configured as a default_character_set=utf-8

Then sqlalchemy the character encoding format used to create the table is Latin1, as follows

| Log   | CREATE TABLE`Log' (' ID 'int( One) not NULLauto_increment, ' record_id 'int( One)DEFAULT NULL, ' command 'varchar( -)DEFAULT NULL, ' SN 'varchar( -)DEFAULT NULL, ' hostname 'varchar( -)DEFAULT NULL, ' IDC 'varchar( -)DEFAULT NULL, ' IP 'varchar( -)DEFAULT NULL, ' Iloip 'varchar( -)DEFAULT NULL, ' result 'text, ' Req_time 'datetime DEFAULT NULL, ' Resp_time 'datetime DEFAULT NULL,  PRIMARY KEY(' id '),KEY' record_id ' (' record_id ')) ENGINE=MyISAM auto_increment=2 DEFAULTCHARSET=Latin1|

So even if the engine was created when the character was set to UTF8, the storage is also garbled, the problem is still out of the configuration of MySQL server.

" Mysql+pymysql://work:[email Protected]:3306/work?charset=utf8 "

In addition also to the established database of the character also changed to Utf8:alter database Clubot character set UTF8;

Deleted the existing table, new after the OK.

Flask_sqlalchemy garbled problem

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.