| 709 | |
| 710 | |
| 711 | def _initialize_conn( |
| 712 | db_path: str, enable_sqlite_vec: bool = False |
| 713 | ) -> sqlite3.Connection: |
| 714 | Path(db_path).parent.mkdir(exist_ok=True) |
| 715 | db = sqlite3.connect( |
| 716 | db_path, |
| 717 | detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES, |
| 718 | check_same_thread=False, |
| 719 | ) |
| 720 | if enable_sqlite_vec: |
| 721 | try: |
| 722 | import sqlite_vec # noqa: F401 |
| 723 | except ModuleNotFoundError: |
| 724 | logging.warning("Cannot use sqlite_vec for vector search") |
| 725 | |
| 726 | db.enable_load_extension(True) |
| 727 | sqlite_vec.load(db) |
| 728 | |
| 729 | return db |
| 730 | |
| 731 | |
| 732 | def _table_id(project: str, table: Any, enable_versioning: bool = False) -> str: |