Reputation: 11
In my embedding table created with PGVector I added data from another table so that I could perform the varied searches correctly. However, I forgot to add one of the columns from the other table, the "language" column. Is it possible for me to just add this column without overwriting what already exists?
Next, I will show the code I used to perform the operation.
import psycopg2
from langchain_core.documents import Document
try:
conn = psycopg2.connect(connection_string)
cursor = conn.cursor()
cursor.execute("""
SELECT id_company_training, company_id, dialog, question, answer, "language" FROM company_training WHERE type = 'COMPANY_INTENTS'
""")
records = cursor.fetchall()
for row in records:
id_company_training, company_id, dialog, question, answer = row
if len(question)>0:
vector_db.add_documents([Document(page_content=question, metadata={
'id_company_training':id_company_training,
'company_id': company_id,
'dialog': dialog,
'question': question,
'answer': answer
})])
cursor.close()
conn.close()
except Exception as e:
print(f"Erro ao conectar ao banco de dados: {e}")
I haven't performed any execution yet because I'm afraid of overwriting my table.
Upvotes: 0
Views: 299