storage yaratildi
This commit is contained in:
57
inspect_firestore.py
Normal file
57
inspect_firestore.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import firebase_admin
|
||||
from firebase_admin import credentials
|
||||
from firebase_admin import firestore
|
||||
import json
|
||||
import os
|
||||
|
||||
# Firebase Service Account JSON fayl yo'li
|
||||
cert_path = "fondexuzb-firebase-adminsdk-fbsvc-7b0e2d6200.json"
|
||||
|
||||
if not os.path.exists(cert_path):
|
||||
print(f"Xatolik: {cert_path} fayli topilmadi!")
|
||||
exit(1)
|
||||
|
||||
cred = credentials.Certificate(cert_path)
|
||||
firebase_admin.initialize_app(cred)
|
||||
|
||||
db = firestore.client()
|
||||
|
||||
def inspect_data():
|
||||
# Tekshirib ko'radigan variantlar
|
||||
collections_to_check = [
|
||||
'vendor_categories',
|
||||
'product_categories',
|
||||
'categories',
|
||||
'brand_categories'
|
||||
]
|
||||
|
||||
class DateTimeEncoder(json.JSONEncoder):
|
||||
def default(self, obj):
|
||||
if hasattr(obj, 'isoformat'):
|
||||
return obj.isoformat()
|
||||
if hasattr(obj, 'latitude') and hasattr(obj, 'longitude'):
|
||||
return {'latitude': obj.latitude, 'longitude': obj.longitude}
|
||||
return str(obj)
|
||||
|
||||
for col_name in collections_to_check:
|
||||
print(f"\n--- {col_name} kolleksiyasini tekshirish ---")
|
||||
|
||||
# 3 tadan hujjatni olish (bo'sh bo'lmaganini topish uchun)
|
||||
docs = db.collection(col_name).limit(3).stream()
|
||||
|
||||
found = False
|
||||
for doc in docs:
|
||||
data = doc.to_dict()
|
||||
if not data:
|
||||
continue
|
||||
|
||||
found = True
|
||||
print(f"Hujjat ID: {doc.id}")
|
||||
print(json.dumps(data, indent=4, ensure_ascii=False, cls=DateTimeEncoder))
|
||||
break # Bitta to'la hujjat yetarli
|
||||
|
||||
if not found:
|
||||
print(f"{col_name} kolleksiyasi topilmadi yoki barcha olingan hujjatlar bo'sh!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
inspect_data()
|
||||
Reference in New Issue
Block a user