-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDBOps.py
34 lines (26 loc) · 1.1 KB
/
DBOps.py
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
import os
from pymongo import MongoClient
from dotenv import load_dotenv
import pinecone
def del_mongo():
load_dotenv()
client = MongoClient(os.getenv('MONGO_CONNECT_URI'))
database = client['Spotter'] # Replace 'mydatabase' with your actual database name
collection = database['SpotterClothesData'] # Replace 'mycollection' with your actual collection name
# Clear all documents from the collection
result = collection.delete_many({})
# Print the result (number of documents deleted)
print(f"{result.deleted_count} documents deleted from the collection.")
def del_pinecone():
load_dotenv()
PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
pinecone.init(api_key=PINECONE_API_KEY, environment="gcp-starter")
pinecone.delete_index("spotter")
def create_vector_db_index():
load_dotenv()
PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
pinecone.init(api_key=PINECONE_API_KEY, environment="gcp-starter")
pinecone.create_index("spotter", dimension = 1536, metric = "cosine", pod_type="starter")
# del_mongo()
# del_pinecone()
# create_vector_db_index()