summaryrefslogtreecommitdiff
path: root/rag/retriever
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-09 23:55:58 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-09 23:55:58 +0200
commit040aff556698ed96fa8b62f10033a0d9e8e9d0f5 (patch)
tree610e42bf9d51abbc864b6230b18d5656a7f57620 /rag/retriever
parent03fff940a0c1bf228f8754e4e4a07814bacf5369 (diff)
Fix data type for postgres
Diffstat (limited to 'rag/retriever')
-rw-r--r--rag/retriever/document.py13
1 files changed, 8 insertions, 5 deletions
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,),