A Sqlite table managed by Feast. Attributes: path: The absolute path of the Sqlite file. name: The name of the table. conn: SQLite connection.
| 734 | |
| 735 | |
| 736 | class SqliteTable(InfraObject): |
| 737 | """ |
| 738 | A Sqlite table managed by Feast. |
| 739 | |
| 740 | Attributes: |
| 741 | path: The absolute path of the Sqlite file. |
| 742 | name: The name of the table. |
| 743 | conn: SQLite connection. |
| 744 | """ |
| 745 | |
| 746 | path: str |
| 747 | conn: sqlite3.Connection |
| 748 | |
| 749 | def __init__(self, path: str, name: str): |
| 750 | super().__init__(name) |
| 751 | self.path = path |
| 752 | self.conn = _initialize_conn(path) |
| 753 | |
| 754 | def to_infra_object_proto(self) -> InfraObjectProto: |
| 755 | sqlite_table_proto = self.to_proto() |
| 756 | return InfraObjectProto( |
| 757 | infra_object_class_type=SQLITE_INFRA_OBJECT_CLASS_TYPE, |
| 758 | sqlite_table=sqlite_table_proto, |
| 759 | ) |
| 760 | |
| 761 | def to_proto(self) -> Any: |
| 762 | sqlite_table_proto = SqliteTableProto() |
| 763 | sqlite_table_proto.path = self.path |
| 764 | sqlite_table_proto.name = self.name |
| 765 | return sqlite_table_proto |
| 766 | |
| 767 | @staticmethod |
| 768 | def from_infra_object_proto(infra_object_proto: InfraObjectProto) -> Any: |
| 769 | return SqliteTable( |
| 770 | path=infra_object_proto.sqlite_table.path, |
| 771 | name=infra_object_proto.sqlite_table.name, |
| 772 | ) |
| 773 | |
| 774 | @staticmethod |
| 775 | def from_proto(sqlite_table_proto: SqliteTableProto) -> Any: |
| 776 | return SqliteTable( |
| 777 | path=sqlite_table_proto.path, |
| 778 | name=sqlite_table_proto.name, |
| 779 | ) |
| 780 | |
| 781 | def update(self): |
| 782 | if sys.version_info[0:2] == (3, 10): |
| 783 | try: |
| 784 | import sqlite_vec # noqa: F401 |
| 785 | |
| 786 | self.conn.enable_load_extension(True) |
| 787 | sqlite_vec.load(self.conn) |
| 788 | except ModuleNotFoundError: |
| 789 | logging.warning("Cannot use sqlite_vec for vector search") |
| 790 | self.conn.execute( |
| 791 | f""" |
| 792 | CREATE TABLE IF NOT EXISTS {self.name} ( |
| 793 | entity_key BLOB, |
no outgoing calls