-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_db.py
More file actions
36 lines (30 loc) · 898 Bytes
/
delete_db.py
File metadata and controls
36 lines (30 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import typesense
import sys
TYPESENSE_API_KEY = "Vze6BWbTyu5TFI0qu8Z3HStqofVyoD7EHlNFryIFSJGK9mi3"
client = typesense.Client({
'nodes': [{
'host': 'localhost',
'port': '8108',
'protocol': 'http'
}],
'api_key': TYPESENSE_API_KEY,
'connection_timeout_seconds': 2
})
# List all collections
collections = client.collections.retrieve()
# print(collections)
if collections == []:
print("No collections found")
sys.exit()
else:
print("Current collections:")
for col in collections:
print(f" - {col['name']} ({col['num_documents']} docs)")
a = input("Delete all databases?(y/n)")
if a == "y":
# Delete old langchain-* collections
for col in collections:
if col['name']:
print(f"Deleting: {col['name']}")
client.collections[col['name']].delete()
print("\n✓ Cleanup complete!")