How can I check whether my prisma connection is up...
# orm-help
n
How can I check whether my prisma connection is up and running or not via code? I need to implement a database health service API in prisma.
j
A raw query
SELECT 1
should do that job.
n
yeah I thought about querying and checking but is there any other way? btw thx for your quick response
r
I don’t think so and that’s how we do it in Prisma afaik.
n
Ok thx
👍 1
j
Querying is the only way that will really give you an answer you can trust.
Which is why Prisma also uses that internally to check if connections are alive etc.
By just doing
SELECT 1
no tables are read or blocked or anything, so the query returns as fast as possible.
👍 1
n
Ok so If i have a model named User, so I need to make a raw query like "Select 1 from User" , right?
r
Just
select 1
. No tables need to be mentioned.
n
ok
Thx guys it worked perfectly fine :)
💯 2