Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

fix: no logging in pysqlite replacement (#378)

cachho5e94980aaa80
diff --git a/embedchain/utils.py b/embedchain/utils.py
index 7a4f2b1d8..d0a7c1e18 100644
--- a/embedchain/utils.py
+++ b/embedchain/utils.py
@@ -1,4 +1,3 @@
-import logging
import re
import string
@@ -53,15 +52,25 @@ def use_pysqlite3():
Swap std-lib sqlite3 with pysqlite3.
"""
import platform
+ import sqlite3
- if platform.system() == "Linux":
+ if platform.system() == "Linux" and sqlite3.sqlite_version_info < (3, 35, 0):
# According to the Chroma team, this patch only works on Linux
+ import datetime
import subprocess
import sys
- subprocess.check_call([sys.executable, "-m", "pip", "install", "pysqlite3-binary"])
+ subprocess.check_call(
+ [sys.executable, "-m", "pip", "install", "pysqlite3-binary", "--quiet", "--disable-pip-version-check"]
+ )
__import__("pysqlite3")
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
- # Don't be surprised if this doesn't log as you expect, because the logger is instantiated after the import
- logging.info("Swapped std-lib sqlite3 with pysqlite3")
+
+ # Let the user know what happened.
+ current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
+ print(
+ f"{current_time} [embedchain] [INFO]",
+ "Swapped std-lib sqlite3 with pysqlite3 for ChromaDb compatibility.",
+ f"Your original version was {sqlite3.sqlite_version}.",
+ )