Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This tool does not support Chinese? #376

Open
craneyuan opened this issue Jan 5, 2018 · 4 comments
Open

This tool does not support Chinese? #376

craneyuan opened this issue Jan 5, 2018 · 4 comments

Comments

@craneyuan
Copy link

When I try to format an SQL statement containing Chinese, it gives the following error.

select * from mytest where name='测试';
Error: Traceback (most recent call last):
  File "/usr/local/bin/sqlformat", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/sqlparse/cli.py", line 180, in main
    stream.write(s)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 33-34: ordinal not in range(128)
    at /Users/craneyuan/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:182:23
    at tryCatcher (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:143:10)
    at Async.drainQueues (/Users/craneyuan/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
    at process._tickCallback (internal/process/next_tick.js:103:7)
@nihao
Copy link

nihao commented Jan 31, 2018

All characters are encoding with 'utf-8' in python3. And I also using Chinese characters in my project, no any problem.

So, I think your issue may be due to pass a wrong encoding ('ascii') string to SQLParse.

It is not a problem of 'SQLParse'.

@Junzerg
Copy link

Junzerg commented May 17, 2018

我也遇到了这个问题,SQL中不能有中文,请问你解决了么?

@craneyuan
Copy link
Author

@Junzerg 没有,我换其他工具了 😭

@longxudou
Copy link

@craneyuan 能提供下新工具的名字吗?

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

No branches or pull requests

4 participants