Archery icon indicating copy to clipboard operation
Archery copied to clipboard

1.9.1 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 1: ordinal not in range(128)

Open solomon-cc opened this issue 2 years ago • 3 comments

重现步骤

使用的是1.9.1版本,用的helm部署。实例pgsql 返回结果有中文,页面查询报错。 在程序内部打印编码,显示为utf-8,尝试在values添加环境变量解决问题,没有成功 LC_ALL="en_US.UTF-8" LANG="zh_CN.GBK"

程序内部使用locale -a 显示编码为 LANG=zh_CN.GBK LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8

预期外的结果

image image

日志文本

切换python运行环境
修改重定向端口
启动nginx
收集所有的静态文件到STATIC_ROOT
utf-8
启动Django Q cluster
启动服务
[2023-04-17 09:45:12,914][MainThread:140463363778368][task_id:default][pgsql.py:195][WARNING]- PgSQL命令执行报错,语句:select
        col.column_name,
        col.data_type,
        col.character_maximum_length,
        col.numeric_precision,
        col.numeric_scale,
        col.is_nullable,
        col.column_default,
        des.description
        from
        information_schema.columns col left join pg_description des on
        col.table_name::regclass = des.objoid
        and col.ordinal_position = des.objsubid
        where table_name = 'realtime_alarm_info'
        and col.table_schema = 'public'
        order by ordinal_position;, 错误信息:Traceback (most recent call last):
  File "/opt/archery/sql/engines/pgsql.py", line 188, in query
    rows = cursor.fetchall()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 1: ordinal not in range(128)

版本

1.9.1

部署方式

K8S

是否还有其他可以辅助定位问题的信息?比如数据库版本等

MySQL: 5.7 Browsers: Chrome image

solomon-cc avatar Apr 17 '23 01:04 solomon-cc

设置集群的时候可以指定连接编码,你要指定为utf8

LeoQuote avatar Apr 17 '23 02:04 LeoQuote

https://github.com/hhyo/Archery/blob/7632b3d8a1249bd8aa99abf58547c8cd4748795e/sql/engines/pgsql.py#L33 这里没引用编码,还得改一改,你可以提个pr

LeoQuote avatar Apr 17 '23 02:04 LeoQuote

ok,我看看把

solomon-cc avatar Apr 17 '23 02:04 solomon-cc