RobertCraigie / prisma-client-py

Prisma Client Python is an auto-generated and fully type-safe database client designed for ease of use
https://prisma-client-py.readthedocs.io
Apache License 2.0
1.89k stars 81 forks source link

About UnicodeEncodeError #1046

Open wxxtaiyang opened 3 days ago

wxxtaiyang commented 3 days ago

Error Message

Error: Traceback (most recent call last): File "D:\Pyenv\pyenv-win-master\pyenv-win\versions\3.10.8\lib\site-packages\prisma\generator\generator.py", line 106, in run self._on_request(request) File "D:\Pyenv\pyenv-win-master\pyenv-win\versions\3.10.8\lib\site-packages\prisma\generator\generator.py", line 159, in _on_request self.generate(data) File "D:\Pyenv\pyenv-win-master\pyenv-win\versions\3.10.8\lib\site-packages\prisma\generator\generator.py", line 241, in generate packaged_schema.write_text(data.datamodel) File "D:\Pyenv\pyenv-win-master\pyenv-win\versions\3.10.8\lib\pathlib.py", line 1155, in write_text return f.write(data) UnicodeEncodeError: 'gbk' codec can't encode character '\udc80' in position 253: illegal multibyte sequence

My prisma is 0.15.0 My schema.prisma file

datasource db {
    // provider = "sqlite"
    provider = "postgresql"
    url      = env("DATABASE_URL")
}

generator client {
    provider             = "prisma-client-py"
    recursive_type_depth = 5
    interface            = "asyncio"
}

// 教职工基础数据事实表 DW_JG_JZGJCSJ
model DW_JG_JZGJCSJ {
    ID        String  @id @default(cuid()) // 主键
    GH        String? // 工号
    DWH       String? // 单位号
    XM        String? // 姓名
}

what should I do?

wxxtaiyang commented 3 days ago

I solved the problem update generate.py

241 // packaged_schema.write_text(data.datamodel)
241 packaged_schema.write_text(data.datamodel,encoding='UTF-7')