sqlparse
sqlparse copied to clipboard
This tool does not support Chinese?
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)
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'.
我也遇到了这个问题,SQL中不能有中文,请问你解决了么?
@Junzerg 没有,我换其他工具了 😭
@craneyuan 能提供下新工具的名字吗?