Skip to main content
LangChain’s MariaDB integration (langchain-mariadb) provides vector capabilities for working with MariaDB version 11.7.1 and above, distributed under the MIT license. Users can use the provided implementations as-is or customize them for specific needs. Key features include:
  • Built-in vector similarity search
  • Support for cosine and euclidean distance metrics
  • Robust metadata filtering options
  • Performance optimization through connection pooling
  • Configurable table and column settings

Setup

Launch a MariaDB Docker container with:

Installing the package

The package uses SQLAlchemy but works best with the MariaDB connector, which requires C/C++ components:
Then install langchain-mariadb package
VectorStore works along with an LLM model, here using langchain-openai as example.

Initialization

Manage vector store

Adding data

You can add data as documents with metadata:
Or as plain text with optional metadata:

Query vector store

Filter options

The system supports various filtering operations on metadata:
  • Equality: $eq
  • Inequality: $ne
  • Comparisons: lt,lt, lte, gt,gt, gte
  • List operations: in,in, nin
  • Text matching: like,like, nlike
  • Logical operations: and,and, or, $not
Example:

API reference

See the langchain-mariadb API documentation for more detail.