From e8264e80cecfbf440439776aa5c120b0a6110bab Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Sun, 26 Oct 2025 09:36:33 -0400 Subject: [PATCH] Changing DB thing --- Dockerfile | 4 ++-- add_user.py | 4 ++-- aerich_config.py | 2 +- app.py | 2 +- docker-compose.yml | 2 ++ index_immich.py | 2 +- main.py | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb5a966..e6e65b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,8 +35,8 @@ WORKDIR /app/raggr-frontend RUN yarn install && yarn build WORKDIR /app -# Create ChromaDB directory -RUN mkdir -p /app/chromadb +# Create ChromaDB and database directories +RUN mkdir -p /app/chromadb /app/database # Expose port EXPOSE 8080 diff --git a/add_user.py b/add_user.py index 1961003..2380a89 100644 --- a/add_user.py +++ b/add_user.py @@ -10,7 +10,7 @@ from blueprints.users.models import User async def add_user(username: str, email: str, password: str): """Add a new user to the database""" await Tortoise.init( - db_url="sqlite://raggr.db", + db_url="sqlite://database/raggr.db", modules={ "models": [ "blueprints.users.models", @@ -56,7 +56,7 @@ async def add_user(username: str, email: str, password: str): async def list_users(): """List all users in the database""" await Tortoise.init( - db_url="sqlite://raggr.db", + db_url="sqlite://database/raggr.db", modules={ "models": [ "blueprints.users.models", diff --git a/aerich_config.py b/aerich_config.py index d23a0ba..faa1c28 100644 --- a/aerich_config.py +++ b/aerich_config.py @@ -1,7 +1,7 @@ import os TORTOISE_ORM = { - "connections": {"default": os.getenv("DATABASE_URL", "sqlite:///app/raggr.db")}, + "connections": {"default": os.getenv("DATABASE_URL", "sqlite:///app/database/raggr.db")}, "apps": { "models": { "models": [ diff --git a/app.py b/app.py index 5f31f8a..2152fa8 100644 --- a/app.py +++ b/app.py @@ -27,7 +27,7 @@ app.register_blueprint(blueprints.conversation.conversation_blueprint) TORTOISE_CONFIG = { - "connections": {"default": "sqlite://raggr.db"}, + "connections": {"default": "sqlite://database/raggr.db"}, "apps": { "models": { "models": [ diff --git a/docker-compose.yml b/docker-compose.yml index 49980d0..36a449a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,8 @@ services: - OPENAI_API_KEY=${OPENAI_API_KEY} volumes: - chromadb_data:/app/chromadb + - database_data:/app/database volumes: chromadb_data: + database_data: diff --git a/index_immich.py b/index_immich.py index 76a67f4..e87f0ce 100644 --- a/index_immich.py +++ b/index_immich.py @@ -27,7 +27,7 @@ headers = {"x-api-key": API_KEY, "Content-Type": "application/json"} VISITED = {} if __name__ == "__main__": - conn = sqlite3.connect("./visited.db") + conn = sqlite3.connect("./database/visited.db") c = conn.cursor() c.execute("select immich_id from visited") rows = c.fetchall() diff --git a/main.py b/main.py index 20b7bf9..847f91f 100644 --- a/main.py +++ b/main.py @@ -77,7 +77,7 @@ def chunk_data(docs, collection, doctypes): logging.info(f"chunking {len(docs)} documents") texts: list[str] = [doc["content"] for doc in docs] - with sqlite3.connect("visited.db") as conn: + with sqlite3.connect("database/visited.db") as conn: to_insert = [] c = conn.cursor() for index, text in enumerate(texts): @@ -189,7 +189,7 @@ def consult_simba_oracle(input: str, transcript: str = ""): def filter_indexed_files(docs): - with sqlite3.connect("visited.db") as conn: + with sqlite3.connect("database/visited.db") as conn: c = conn.cursor() c.execute( "CREATE TABLE IF NOT EXISTS indexed_documents (id INTEGER PRIMARY KEY AUTOINCREMENT, paperless_id INTEGER)"