~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: SQLCipher 4.6 compatibility - use cipher_default_* pragmas
LearningCircuitd5af57ca9d1c
diff --git a/src/local_deep_research/database/encrypted_db.py b/src/local_deep_research/database/encrypted_db.pyindex ab3330a4cb..b3b6a923c4 100644--- a/src/local_deep_research/database/encrypted_db.py+++ b/src/local_deep_research/database/encrypted_db.py@@ -84,10 +84,14 @@ class DatabaseManager:sqlcipher = sqlcipher_module.dbapi2conn = sqlcipher.connect(tmp_path)+ # Use cursor for consistent behavior (same as create_sqlcipher_connection)+ cursor = conn.cursor()# IMPORTANT: For SQLCipher 4.x, cipher settings MUST be set BEFORE the key- apply_cipher_settings_before_key(conn)+ apply_cipher_settings_before_key(cursor)# Use centralized key setting- set_sqlcipher_key(conn, "testpass")+ set_sqlcipher_key(cursor, "testpass")+ cursor.close()+ # Now use the connection for table operationsconn.execute("CREATE TABLE test (id INTEGER PRIMARY KEY)")conn.execute("INSERT INTO test VALUES (1)")result = conn.execute("SELECT * FROM test").fetchone()@@ -213,11 +217,15 @@ class DatabaseManager:isolation_level="IMMEDIATE",check_same_thread=False,)+ # Use cursor for consistent behavior (same as create_sqlcipher_connection)+ cursor = conn.cursor()+# IMPORTANT: For SQLCipher 4.x, cipher settings MUST be set BEFORE the key- apply_cipher_settings_before_key(conn)+ apply_cipher_settings_before_key(cursor)# Use centralized SQLCipher setup- set_sqlcipher_key(conn, password)- apply_sqlcipher_pragmas(conn, creation_mode=True)+ set_sqlcipher_key(cursor, password)+ apply_sqlcipher_pragmas(cursor, creation_mode=True)+ cursor.close()# Get the CREATE TABLE statements from SQLAlchemy modelsfrom sqlalchemy.dialects import sqlitediff --git a/src/local_deep_research/database/sqlcipher_utils.py b/src/local_deep_research/database/sqlcipher_utils.pyindex b11c821683..497303615a 100644--- a/src/local_deep_research/database/sqlcipher_utils.py+++ b/src/local_deep_research/database/sqlcipher_utils.py@@ -62,11 +62,16 @@ def set_sqlcipher_rekey(cursor_or_conn: Any, new_password: str) -> None:"""Change the SQLCipher encryption key using hexadecimal encoding.+ Uses the same PBKDF2 key derivation as set_sqlcipher_key() to ensure+ consistency when re-opening databases after password change.+Args:cursor_or_conn: SQLCipher cursor or connection objectnew_password: The new password to use for encryption"""- hex_password = new_password.encode("utf-8").hex()+ # Use the same key derivation as set_sqlcipher_key for consistency+ key = _get_key_from_password(new_password) # gitleaks:allow+ hex_key = key.hex()# Handle SQLAlchemy connections that need text()if hasattr(cursor_or_conn, "execute") and hasattr(@@ -77,12 +82,12 @@ def set_sqlcipher_rekey(cursor_or_conn: Any, new_password: str) -> None:# SQLAlchemy doesn't support parameterized PRAGMA, so we use the safe hex encoding# The hex encoding already prevents injection since it only contains [0-9a-f]- safe_sql = f"PRAGMA rekey = \"x'{hex_password}'\""+ safe_sql = f"PRAGMA rekey = \"x'{hex_key}'\""cursor_or_conn.execute(text(safe_sql))else:# Raw SQLCipher connection - also doesn't support parameterized PRAGMA# The hex encoding already prevents injection since it only contains [0-9a-f]- safe_sql = f"PRAGMA rekey = \"x'{hex_password}'\""+ safe_sql = f"PRAGMA rekey = \"x'{hex_key}'\""cursor_or_conn.execute(safe_sql)@@ -140,9 +145,12 @@ def apply_cipher_settings_before_key("""Apply SQLCipher cipher settings that MUST be set BEFORE the key.- In SQLCipher 4.x, cipher_page_size and cipher_hmac_algorithm must be- set BEFORE PRAGMA key is executed. This function should be called- immediately after connection, before set_sqlcipher_key().+ In SQLCipher 4.x, cipher_default_* pragmas must be set BEFORE PRAGMA key+ is executed. This function should be called immediately after connection,+ before set_sqlcipher_key().++ Note: In SQLCipher 4.6+ Community Edition, use cipher_default_page_size+ instead of cipher_page_size for new databases.Args:cursor_or_conn: SQLCipher cursor or connection object@@ -151,12 +159,15 @@ def apply_cipher_settings_before_key(settings = get_sqlcipher_settings(username)# These MUST be set BEFORE the key for SQLCipher 4.x compatibility- cursor_or_conn.execute(f"PRAGMA cipher_page_size = {settings['page_size']}")+ # Use cipher_default_* pragmas for SQLCipher 4.6+ Community Edition+ cursor_or_conn.execute(+ f"PRAGMA cipher_default_page_size = {settings['page_size']}"+ )cursor_or_conn.execute(- f"PRAGMA cipher_hmac_algorithm = {settings['hmac_algorithm']}"+ f"PRAGMA cipher_default_hmac_algorithm = {settings['hmac_algorithm']}")cursor_or_conn.execute(- f"PRAGMA cipher_kdf_algorithm = {settings['kdf_algorithm']}"+ f"PRAGMA cipher_default_kdf_algorithm = {settings['kdf_algorithm']}")