DuckDB(
self,
*,
connection: Optional[Any] = None,
embedding: Embeddings| Name | Type | Description |
|---|---|---|
connection | Optional[Any] | Default: NoneOptional DuckDB connection |
embedding* | Embeddings | The embedding function or model to use for generating embeddings. |
vector_key | str | Default: DEFAULT_VECTOR_KEY |
id_key | str | Default: DEFAULT_ID_KEY |
text_key | str | Default: DEFAULT_TEXT_KEY |
table_name | str | Default: DEFAULT_TABLE_NAME |
DuckDB vector store.
This class provides a vector store interface for adding texts and performing similarity searches using DuckDB.
For more information about DuckDB, see: https://duckdb.org/
This integration requires the duckdb Python package.
You can install it with pip install duckdb.
Security Notice: The default DuckDB configuration is not secure.
By **default**, DuckDB can interact with files across the entire file system,
which includes abilities to read, write, and list files and directories.
It can also access some python variables present in the global namespace.
When using this DuckDB vectorstore, we suggest that you initialize the
DuckDB connection with a secure configuration.
For example, you can set `enable_external_access` to `false` in the connection
configuration to disable external access to the DuckDB connection.
You can view the DuckDB configuration options here:
https://duckdb.org/docs/configuration/overview.html
Please review other relevant security considerations in the DuckDB
documentation. (e.g., "autoinstall_known_extensions": "false",
"autoload_known_extensions": "false")
See https://python.langchain.com/docs/security for more information.
Example:
.. code-block:: python
import duckdb conn = duckdb.connect(database=':memory:', config={ # Sample configuration to restrict some DuckDB capabilities # List is not exhaustive. Please review DuckDB documentation. "enable_external_access": "false", "autoinstall_known_extensions": "false", "autoload_known_extensions": "false" } ) embedding_function = ... # Define or import your embedding function here vector_store = DuckDB(conn, embedding_function) vector_store.add_texts(['text1', 'text2']) result = vector_store.similarity_search('text1')
The column name for storing vectors. Defaults to embedding.
The column name for storing unique identifiers. Defaults to id.
The column name for storing text. Defaults to text.
The name of the table to use for storing embeddings. Defaults to
embeddings.