array_length(embedding, 1) = {self.ndims}),
metadata json,
document text);"""
        )
        self.cursor.execute(
            f"call set_table_property('{self.table_name}'"
            + """, 'proxima_vectors', 
'{"embedding":{"algorithm":"Graph",
"distance_method":"SquaredEuclidean",
"build_params":{"min_flush_proxima_row_count" : 1,
"min_compaction_proxima_row_count" : 1, 
"max_total_size_to_merge_mb" : 2000}}}');"""
        )
        self.conn.commit()
[docs]    def get_by_id(self, id: str) -> List[Tuple]:
        statement = (
            f"select id, embedding, metadata, "
            f"document from {self.table_name} where id = %s;"
        )
        self.cursor.execute(
            statement,
            (id),
        )
        self.conn.commit()
        return self.cursor.fetchall()
[docs]    def insert(
        self,
        embedding: List[float],
        metadata: dict,
        document: str,
        id: Optional[str] = None,
    ) -> None:
        self.cursor.execute(
            f'insert into "{self.table_name}" '
            f"values (%s, array{json.dumps(embedding)}::float4[], %s, %s)",
            (id if id is not None else "null", json.dumps(metadata), document),
        )
        self.conn.commit()
[docs]    def query_nearest_neighbours(
        self, embedding: List[float], k: int, filter: Optional[Dict[str, str]] = None
    ) -> List[Tuple[str, str, float]]:
        params = []
        filter_clause = ""