mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-16 06:23:09 +00:00
(fix) re-connect prisma if not connected
This commit is contained in:
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user