Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-8: ordinal not in range(256) #118

Open
YOOC94 opened this issue Mar 26, 2019 · 3 comments

Comments

@YOOC94
Copy link

YOOC94 commented Mar 26, 2019

The Chinese comment in the mysql table, an error is reported during the conversion:

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-8: ordinal not in range(256)

How to solve this problem?

@ssu1980
Copy link

ssu1980 commented Mar 26, 2019

Hi, I can't resolve this problem. I find different path for convert data (xml)

@kworr
Copy link
Collaborator

kworr commented Mar 26, 2019

Can you provide some minified example demonstrating the problem? MySQL database dump preferred.

@YOOC94
Copy link
Author

YOOC94 commented Mar 26, 2019

Mysql statement to create a table:

CREATE TABLE auth_user(user_idbigint(11) NOT NULL AUTO_INCREMENT,usernamevarchar(20) NOT NULL COMMENT '用户名、登录名',nicknamevarchar(20) NOT NULL COMMENT '姓名',passwordvarchar(50) NOT NULL,create_timetimestamp NULL DEFAULT CURRENT_TIMESTAMP,update_time timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (user_id) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='用户表(登录账号)';

When mysql database has the above table, use py-mysql2pgsql to convert create table statement will be the following error:
comments.append('COMMENT ON TABLE %s is %s;' % (table.name, QuotedString(table.comment).getquoted()))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-8: ordinal not in range(256)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants