forked from phoenix/litellm-mirror
(fix) re-connect prisma if not connected
This commit is contained in:
parent
d2578f0cd2
commit
90973d92bf
1 changed files with 11 additions and 0 deletions
|
@ -395,6 +395,10 @@ class PrismaClient:
|
|||
Add a key to the database. If it already exists, do nothing.
|
||||
"""
|
||||
try:
|
||||
# incase prisma is not connected
|
||||
if self.db.is_connected() == False:
|
||||
await self.connect()
|
||||
|
||||
if table_name == "user+key":
|
||||
token = data["token"]
|
||||
hashed_token = self.hash_token(token=token)
|
||||
|
@ -473,6 +477,10 @@ class PrismaClient:
|
|||
Update existing data
|
||||
"""
|
||||
try:
|
||||
# incase prisma is not connected
|
||||
if self.db.is_connected() == False:
|
||||
await self.connect()
|
||||
|
||||
db_data = self.jsonify_object(data=data)
|
||||
if token is not None:
|
||||
print_verbose(f"token: {token}")
|
||||
|
@ -515,6 +523,9 @@ class PrismaClient:
|
|||
Allow user to delete a key(s)
|
||||
"""
|
||||
try:
|
||||
# incase prisma is not connected
|
||||
if self.db.is_connected() == False:
|
||||
await self.connect()
|
||||
hashed_tokens = [self.hash_token(token=token) for token in tokens]
|
||||
await self.db.litellm_verificationtoken.delete_many(
|
||||
where={"token": {"in": hashed_tokens}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue