43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import firebase_admin
|
|
from firebase_admin import credentials
|
|
from firebase_admin import firestore
|
|
import json
|
|
import os
|
|
|
|
cert_path = "fondexuzb-firebase-adminsdk-fbsvc-7b0e2d6200.json"
|
|
|
|
if not os.path.exists(cert_path):
|
|
print(f"Xatolik: {cert_path} fayli topilmadi!")
|
|
exit(1)
|
|
|
|
if not firebase_admin._apps:
|
|
cred = credentials.Certificate(cert_path)
|
|
firebase_admin.initialize_app(cred)
|
|
|
|
db = firestore.client()
|
|
|
|
def inspect_products():
|
|
print(f"\n--- vendor_products kolleksiyasini tekshirish ---")
|
|
|
|
docs = db.collection('vendor_products').limit(5).stream()
|
|
|
|
class DateTimeEncoder(json.JSONEncoder):
|
|
def default(self, obj):
|
|
if hasattr(obj, 'isoformat'):
|
|
return obj.isoformat()
|
|
return str(obj)
|
|
|
|
for doc in docs:
|
|
data = doc.to_dict()
|
|
print(f"Hujjat ID: {doc.id}")
|
|
# Print only keys that might be relevant to attributes
|
|
for key, value in data.items():
|
|
if 'attr' in key.lower() or 'spec' in key.lower():
|
|
print(f" {key}: {value}")
|
|
# Print everything for the first one to be sure
|
|
print(json.dumps(data, indent=4, ensure_ascii=False, cls=DateTimeEncoder))
|
|
print("-" * 20)
|
|
|
|
if __name__ == "__main__":
|
|
inspect_products()
|