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.87k stars 81 forks source link

Don't work with prisma>=5.3.0 #821

Closed MarioYoo closed 1 year ago

MarioYoo commented 1 year ago

Config setting:

# pyproject.toml

[tool.prisma]
prisma_version="5.3.1"
expected_engine_version="61e140623197a131c2a6189271ffee05a7aa9a59"

When I run some query operation code, such as:

async def main():
    async with Prisma(http={"timeout": None}) as db:
        await db.user.create({"username": "admin", "password": "123456"})

if __name__ == "__main__":
    asyncio.run(main())

then I get an error:

Traceback (most recent call last):
  File "D:\python workspaces\20230912\dbdemo\.venv\lib\site-packages\prisma\engine\query.py", line 200, in spawn 
    data = await self.request('GET', '/status')
  File "D:\python workspaces\20230912\dbdemo\.venv\lib\site-packages\prisma\engine\http.py", line 122, in request
    errors_data = response.get('errors')
AttributeError: 'str' object has no attribute 'get'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "d:\python workspaces\20230912\dbdemo\src\dbdemo\db\new.py", line 12, in <module>
    asyncio.run(main())
  File "D:\PythonTools\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\PythonTools\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "d:\python workspaces\20230912\dbdemo\src\dbdemo\db\new.py", line 7, in main
    async with Prisma(http={"timeout": None}) as db:
  File "D:\python workspaces\20230912\dbdemo\.venv\lib\site-packages\prisma\client.py", line 227, in __aenter__
    await self.connect()
  File "D:\python workspaces\20230912\dbdemo\.venv\lib\site-packages\prisma\client.py", line 279, in connect
    await self.__engine.connect(
  File "D:\python workspaces\20230912\dbdemo\.venv\lib\site-packages\prisma\engine\query.py", line 136, in connect
    await self.spawn(file, timeout=timeout, datasources=datasources)
  File "D:\python workspaces\20230912\dbdemo\.venv\lib\site-packages\prisma\engine\query.py", line 219, in spawn
    raise errors.EngineConnectionError(
prisma.engine.errors.EngineConnectionError: Could not connect to the query engine
RobertCraigie commented 1 year ago

Sorry for the delay in getting v5 out, there were some breaking changes internally that are fairly difficult to resolve. It should hopefully be out soon.

For reference, the issue that actually causes the error would be fixed with this PR https://github.com/prisma/prisma-engines/pull/4246