auto flush databases
This commit is contained in:
@@ -8,6 +8,8 @@ import json
|
|||||||
import psycopg2
|
import psycopg2
|
||||||
import pymongo
|
import pymongo
|
||||||
|
|
||||||
|
import mongo_conn
|
||||||
|
import pgvec_conn
|
||||||
import redis_conn
|
import redis_conn
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
@@ -91,7 +93,13 @@ def insert_data_mongo(id, filepath,pChunk):
|
|||||||
|
|
||||||
def reload_files():
|
def reload_files():
|
||||||
# path = input("Please provider path to folder: ")
|
# path = input("Please provider path to folder: ")
|
||||||
contents = retrieve_file_contents("C:\\SoftwareEng")
|
pgvec_conn.flush_pg()
|
||||||
|
redis_conn.flush_redis()
|
||||||
|
mongo_conn.flush_mongo()
|
||||||
|
|
||||||
|
provided_path = input("Please Provide Full Qualified Path: ")
|
||||||
|
|
||||||
|
contents = retrieve_file_contents(provided_path)
|
||||||
create_embeddings(contents)
|
create_embeddings(contents)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import pymongo
|
||||||
|
|
||||||
|
def flush_mongo():
|
||||||
|
client = pymongo.MongoClient('mongodb://python:PasswordPassword123@localhost:27017/')
|
||||||
|
mongodb = client['document_table']
|
||||||
|
mongodb.drop_collection("documents")
|
||||||
|
client.close()
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import psycopg2
|
||||||
|
|
||||||
|
def flush_pg():
|
||||||
|
conn = psycopg2.connect(
|
||||||
|
dbname="embeddings",
|
||||||
|
user="python",
|
||||||
|
password="PasswordPassword123",
|
||||||
|
host="localhost",
|
||||||
|
port="5555"
|
||||||
|
)
|
||||||
|
cur = conn.cursor()
|
||||||
|
|
||||||
|
cur.execute("drop table if exists dbtable;")
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
conn.close()
|
||||||
+1
-1
@@ -11,7 +11,7 @@ def load_response_from_redis(prompt):
|
|||||||
r.close()
|
r.close()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def clear_redis():
|
def flush_redis():
|
||||||
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
|
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
|
||||||
r.flushall()
|
r.flushall()
|
||||||
r.close()
|
r.close()
|
||||||
Reference in New Issue
Block a user