Files
gitlab-instance-0a899031_pa…/app/services/pb.py
2026-03-10 04:42:05 -05:00

25 lines
632 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""PocketBase 客户端(基于 SDK"""
from app.config import PB_URL, PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD
from app.sdk.pocketbase import PocketBaseSDK
_pb_sdk: PocketBaseSDK | None = None
def _get_pb_sdk() -> PocketBaseSDK:
global _pb_sdk
if _pb_sdk is None:
_pb_sdk = PocketBaseSDK(
url=PB_URL,
admin_email=PB_ADMIN_EMAIL,
admin_password=PB_ADMIN_PASSWORD,
)
return _pb_sdk
def get_pb_client():
"""获取已认证的 PocketBase 客户端"""
sdk = _get_pb_sdk()
client = sdk.get_client()
print("PocketBase admin 登录成功")
return client