For the complete documentation index, see llms.txt. This page is also available as Markdown.

Database Integration

MariaDB AI RAG database integration endpoints ingest data directly from MariaDB tables or SQL SELECT queries, converting rows into searchable documents with column-mapped metadata.

Database Integration Endpoints

Ingest from Database Table

POST /documents/ingest-from-table

Purpose: Ingests data directly from a MariaDB table or view, treating it as a CSV data source. This allows for seamless integration with existing database content.

Request body:

{
  "table_name": "customer_feedback",
  "schema_name": "databridge",
  "column_mapping": {
    "content": "feedback_text",
    "metadata": ["customer_id", "product_id", "rating", "date_submitted"],
    "id_column": "feedback_id"
  },
  "filter_condition": "rating >= 3 AND date_submitted > '2025-01-01'",
  "batch_size": 1000,
  "authorized_users": ["user1@example.com", "user2@example.com"]
}

Response:

Usage Example: Use this endpoint to ingest structured data from your database tables or views. The system will process each row as a document, with specified columns as content and metadata.

Ingest from SQL Query

Purpose: Executes a SELECT query and ingests the results as a CSV document. The query results are stored as a document that can be chunked and searched. This provides a way to make database query results searchable via RAG.

Request body:

Request Parameters:

  • sql_query (required): A SELECT query to execute (only SELECT queries are allowed)

  • role (optional): Database role to use for query execution (default: from DEFAULT_SQL_ROLE environment variable)

  • document_name (optional): Name for the generated CSV document (default: "query_results")

Security Notes:

  • Only SELECT queries are allowed (enforced by regex validation)

  • Multiple statements are not allowed (no semicolons outside of quoted strings)

  • User must have permission to use the specified role

  • Query is executed using MariaDB's role-based access control

Response:

Usage Example: Query database and ingest results for RAG search.

Note: The query results are converted to CSV format and stored as a document. You can then chunk this document using the chunking endpoints to make the data searchable.

Check Database Ingestion Status

Purpose: Checks the status of a database ingestion job.

Response:

Usage Example: Use this endpoint to monitor the progress of database ingestion jobs.

This page is: Copyright © 2025 MariaDB. All rights reserved.

spinner

Last updated

Was this helpful?