pythondatabasesqlitenpmprisma

Prisma client python keeps telling me that my client isn't generated, even though I ran the command for it


I am using Prisma Client Python along with SQLite to create a database for my program. I have everything installed correctly, npm, node.js, prisma client, prisma CLI... and I have already created a schema file and ran "prisma generate" and "prisma db push",those gave no errors at all and ran fine. However, when I try to run my program which uses prisma commands, it gives me this error:

Traceback (most recent call last): File "C:\Users\Lukas\source\repos\number_guessing_webhost\number_guessing_webhost.py", line 2, in from prisma import Prisma File "", line 1231, in handle_fromlist File "C:\Users\Lukas\source\repos\number_guessing_webhost\ENV P3.11\Lib\site-packages\prisma_init.py", line 50, in getattr raise RuntimeError( RuntimeError: The Client hasn't been generated yet, you must run prisma generate before you can use the client. See https://prisma-client-py.readthedocs.io/en/stable/reference/troubleshooting/#client-has-not-been-generated-yet Press any key to continue . . .

I have been trying to figure this out for the past few days now and have always hit a brick wall. Any suggestions would be greatly appreciated.

Wanted to run my program to interact with the prisma client python database, resulting in score being tracked and written in the database. Instead the program gave me an error saying i haven't generated the client yet, which I already have.


Solution

  • Normally, the generate or db push commands generate and store the client. If these commands are not helping, the most possible reason is that the client is using some other generator provider. In your case, since the desired usage is with python, the generator provider must be prisma-client-py. If it is something else (ex: prisma-client-js), "generate" command will run smooth, and says that the client has been generated, but it will be generated for js and will be stored in node_modules. And python wont even detect it.

    The fix is pretty straight forward.

    In schema.prisma, change

    generator client {
      provider = "prisma-client-js"
    }
    

    to

    generator client {
      provider = "prisma-client-py"
    }
    

    and run prisma generate again.