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

About UnicodeEncodeError #1046

Open
wxxtaiyang opened this issue Nov 19, 2024 · 1 comment
Open

About UnicodeEncodeError #1046

wxxtaiyang opened this issue Nov 19, 2024 · 1 comment

Comments

@wxxtaiyang
Copy link

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
Copy link
Author

I solved the problem
update generate.py

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

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

1 participant