From 040aff556698ed96fa8b62f10033a0d9e8e9d0f5 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Tue, 9 Apr 2024 23:55:58 +0200 Subject: Fix data type for postgres --- rag/retriever/document.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'rag') diff --git a/rag/retriever/document.py b/rag/retriever/document.py index 67ff936..8a50f01 100644 --- a/rag/retriever/document.py +++ b/rag/retriever/document.py @@ -7,14 +7,17 @@ from loguru import logger as log TABLES = """ CREATE TABLE IF NOT EXISTS document ( - hash text PRIMARY KEY) + hash VARCHAR(64) PRIMARY KEY) """ class DocumentDB: def __init__(self) -> None: self.conn = psycopg.connect( - f"dbname={os.environ['DOCUMENT_DB_NAME']} user={os.environ['DOCUMENT_DB_USER']}" + ( + f"dbname={os.environ['DOCUMENT_DB_NAME']} " + f"user={os.environ['DOCUMENT_DB_USER']}" + ) ) self.__configure() @@ -36,7 +39,7 @@ class DocumentDB: hash = self.__hash(blob) cur.execute( """ - SELECT * FROM document + SELECT * FROM document WHERE hash = %s """, @@ -47,8 +50,8 @@ class DocumentDB: log.debug("Inserting document hash into documents db...") cur.execute( """ - INSERT INTO document - (hash) VALUES + INSERT INTO document + (hash) VALUES (%s) """, (hash,), -- cgit v1.2.3-70-g09d2