Created
January 27, 2025 19:43
-
-
Save ctindel/344eb77be3df69458eebcddf01ad6dc1 to your computer and use it in GitHub Desktop.
Print all Weaviate Collections along with document counts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import weaviate | |
import weaviate.classes as wvc | |
import weaviate.classes.config as wc | |
import os | |
import json | |
try: | |
client = weaviate.connect_to_local(headers={}) | |
assert client.is_live() | |
collections = client.collections.list_all() | |
# Print all collection names | |
for name in collections: | |
print(name) | |
collection = client.collections.get(name) | |
aggregation = collection.aggregate.over_all(total_count=True) | |
print(aggregation.total_count) | |
except Exception as e: | |
print(e) | |
finally: # This will always be executed, even if an exception is raised | |
client.close() # Close the connection & release resources |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment