Datasources¶
Datasources configure database connections. They are stored as individual YAML files in the datasources/ directory.
YAML Format¶
# slayer_data/datasources/my_postgres.yaml
name: my_postgres
type: postgres
host: localhost
port: 5432
database: myapp
username: myuser
password: mypassword
schema_name: public # Optional: default schema
Or with a connection string:
Environment Variables¶
Use ${VAR_NAME} references for credentials — resolved at read time from the process environment:
name: my_postgres
type: postgres
host: ${DB_HOST}
port: 5432
database: ${DB_NAME}
username: ${DB_USER}
password: ${DB_PASSWORD}
Supported Database Types¶
SLayer uses sqlglot for dialect-aware SQL generation. Databases are supported at two tiers:
Database Drivers¶
First-class support¶
These databases are verified by integration tests and runnable Docker examples. Regressions are caught in CI.
| Type | Install Extra | Connection String |
|---|---|---|
sqlite |
(built-in, no extra needed) | sqlite:///path/to/db.sqlite |
postgres / postgresql |
motley-slayer[postgres] |
postgresql://user:pass@localhost:5432/db |
mysql / mariadb |
motley-slayer[mysql] |
mysql+pymysql://user:pass@localhost:3306/db |
clickhouse |
motley-slayer[clickhouse] |
clickhouse+http://user:pass@localhost:8123/db |
duckdb |
motley-slayer[duckdb] |
duckdb:///path/to/db.duckdb |
Additional support¶
SQL generation is covered by unit tests, but not verified against live instances. Install the appropriate SQLAlchemy driver manually.
| Type | SQLAlchemy Driver | Install |
|---|---|---|
snowflake |
snowflake-sqlalchemy |
pip install snowflake-sqlalchemy |
bigquery |
sqlalchemy-bigquery |
pip install sqlalchemy-bigquery |
redshift |
sqlalchemy-redshift + redshift_connector |
pip install sqlalchemy-redshift redshift-connector |
trino / presto / athena |
trino or PyAthena |
pip install trino or pip install PyAthena |
databricks / spark |
databricks-sql-connector |
pip install databricks-sql-connector |
oracle |
oracledb |
pip install oracledb |
mssql / sqlserver / tsql |
pyodbc (auto-generated strings) or pymssql (manual connection_string only) |
pip install pyodbc or pip install pymssql |
SQL Server — requires SQL Server 2022+
SLayer uses DATETRUNC for time-dimension queries, which was introduced in SQL Server 2022 (version 16.0).
SQL Server 2019 and earlier will return an error on time-dimension queries.
The Docker example uses mcr.microsoft.com/mssql/server:2022-latest.
SQL Server — TrustServerCertificate
Auto-generated SQL Server connection strings include TrustServerCertificate=yes, which disables
TLS certificate validation. This is correct for local development and Docker environments that use
self-signed certificates, but must not be used in production — it allows a man-in-the-middle
attack on the database connection. For production, supply a connection_string field directly with
a valid CA certificate chain, or configure your SQL Server instance with a certificate signed by a
trusted CA and omit TrustServerCertificate.
Note
Snowflake, BigQuery, ClickHouse, and similar analytical warehouses typically don't have foreign keys, so auto-ingestion won't discover joins. Define joins manually in your model YAML.
Tip
If your database isn't listed but is supported by sqlglot, it may already work — SLayer falls back to Postgres-style SQL by default. Try it and open an issue if you hit a problem.
Field Reference¶
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Unique datasource name |
type |
string | No | Database type (see above) |
host |
string | No | Database host (default: localhost) |
port |
int | No | Database port |
database |
string | No | Database name |
username |
string | No | Database username |
password |
string | No | Database password |
connection_string |
string | No | Full connection string (alternative to individual fields) |
schema_name |
string | No | Default schema name |
Note
Both username and user field names are accepted. The user alias is automatically mapped to username for compatibility with common database tooling conventions.
Ingesting at Startup¶
To run idempotent auto-ingestion across every configured datasource each time slayer serve or slayer mcp boots, pass --ingest-on-startup (or set SLAYER_INGEST_ON_STARTUP=1). See Ingesting at Startup for the full contract.
Connection Testing¶
When creating a datasource via MCP (create_datasource) or describe_datasource, SLayer automatically tests the connection and reports success or failure with actionable error hints.
Common error hints:
| Error | Hint |
|---|---|
| No password supplied | Check that username and password are correct |
| Database does not exist | Verify the database name |
| Connection refused | Check that the server is running and the port is correct |
| Host not found | Check the host address |