Skip to content
Advertisement

Generating a global connection in prisma python client

I’m using Prisma python client for my mysql database. I’m wondering if its possible to do a single global connection instead of having to open and close them whenever I make a query?

JavaScript

I tried doing the following:

JavaScript

However, I get an error:

JavaScript

Advertisement

Answer

It is recommended that you create one instance of PrismaClient and reuse it across your application and you should only set it to a global variable in the development environment only and you do not need to explicitly $disconnect. You can learn more about Prisma connection management in the docs. Also, I’ll encourage you to ask your Prisma Python client questions in prisma-client-py repositories GitHub Discussion

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement