SELECT query from a MySQL or PostgreSQL database into the mAItion knowledge base. Each returned row becomes one indexed document.
What It Does
- runs a pre-configured
SELECTquery against a MySQL or PostgreSQL database - indexes the
contentcolumn of every row as the body of a document - optionally stores extra columns as document metadata
- runs ingestion on configurable schedules
Query Requirements
The query must return these four columns. Use SQLAS aliases to map your own column names to them:
If the query does not return one of these columns, the ingestion fails and the error names the missing columns.
A row is indexed again when its
updated_at value changes. Make sure updated_at changes every time content changes, otherwise edits to a row can be missed.
Example with aliases:
Use a read-only database account in the connection string. The connector only checks that the query starts with
SELECT or WITH, so it cannot guarantee that a query does not change data.Required Environment Variables
Set these in.env.rag:
DB_POSTGRES1_CONNECTION_STRING: SQLAlchemy connection string for the PostgreSQL source (example:postgresql+psycopg2://user:password@db-host:5432/dbname)DB_POSTGRES1_SCHEDULES: ingestion interval in seconds (default is3600)DB_MYSQL1_CONNECTION_STRING: SQLAlchemy connection string for the MySQL source (example:mysql+pymysql://user:password@db-host:3306/dbname)DB_MYSQL1_SCHEDULES: ingestion interval in seconds (default is3600)
localhost points to the container itself. URL-encode special characters in the password (for example @ becomes %40).
config.yaml Example
.env.rag Example
Configuration Reference
Multiple Database Sources
Add moresources entries (postgres2, mysql2, etc) with separate env vars per source.