Skip to content
Menu

Data-source connectors

View .md

A connector teaches Beacon one kind of data source. Register the ones you need on the AddBeaconServices(...) builder, before UsePostgreSql() / UseSqlServer():

using Beacon.Connector.PostgreSql;
using Beacon.Connector.SqlServer;
builder.Services.AddBeaconServices(builder.Configuration, options => { /* … */ })
.AddPostgreSqlConnector()
.AddSqlServerConnector()
.UsePostgreSql();
EnginePackageRegistration
PostgreSQLMoberg.Beacon.Connector.PostgreSql.AddPostgreSqlConnector()
SQL ServerMoberg.Beacon.Connector.SqlServer.AddSqlServerConnector()
MySQLMoberg.Beacon.Connector.MySql.AddMySqlConnector()
Azure SynapseMoberg.Beacon.Connector.AzureSynapse.AddAzureSynapseConnector()
SnowflakeMoberg.Beacon.Connector.Snowflake.AddSnowflakeConnector()
Google BigQueryMoberg.Beacon.Connector.BigQuery.AddBigQueryConnector()
DatabricksMoberg.Beacon.Connector.Databricks.AddDatabricksConnector()
AWS CloudWatch LogsMoberg.Beacon.Connector.CloudWatch.AddCloudWatchConnector()
REST API (OpenAPI)Moberg.Beacon.Connector.Api.AddApiConnector()

Only registered engines appear in New data source. Data sources themselves (connection details, metadata options, project links) are created in the UI by a DataSourceAdmin or an Admin, and their connection strings are encrypted with Beacon:EncryptionKey before they are stored. See Data sources.

EngineMetadata scanDatabase-level read-onlyRow cap stops the read earlyMigration write target
PostgreSQLYesYes: READ ONLY transaction, one statement per batchYesYes
MySQLYesYes: START TRANSACTION READ ONLY, batches offYesYes
SQL ServerYesNo: runs in a transaction that is always rolled backYesYes
Azure SynapseYesNoYesNo
SnowflakeYesNoYesNo
BigQueryNoNo: the connector’s own parser check plus a dry run whose statement type must be SELECTNo (reads the capped result)No
DatabricksNoNo: the connector’s own parser check and configured catalogNo (reads the capped result)No
CloudWatchLog fieldsn/a (Logs Insights queries, no SQL)n/aNo
REST APIOpenAPI endpointsn/a (HTTP requests, no SQL)n/aNo

Every SQL engine goes through the same execution gate before anything runs: length and character checks, a guardrail, a dialect-aware AST validator, the cross-database rule, a row cap written into the SQL and a statement timeout. Where the database cannot refuse a write itself, the data source shows a badge and Beacon logs a warning at startup and on save.

PostgreSQL

CREATE ROLE beacon_reader LOGIN PASSWORD '…';
GRANT CONNECT ON DATABASE shop TO beacon_reader;
GRANT USAGE ON SCHEMA public TO beacon_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO beacon_reader;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO beacon_reader;
ALTER ROLE beacon_reader SET default_transaction_read_only = on;

SQL Server

CREATE LOGIN beacon_reader WITH PASSWORD = '…';
USE shop;
CREATE USER beacon_reader FOR LOGIN beacon_reader;
ALTER ROLE db_datareader ADD MEMBER beacon_reader;
DENY INSERT, UPDATE, DELETE, ALTER, EXECUTE TO beacon_reader;

MySQL

CREATE USER 'beacon_reader'@'%' IDENTIFIED BY '…';
GRANT SELECT, SHOW VIEW ON shop.* TO 'beacon_reader'@'%';

Snowflake, Synapse, BigQuery, Databricks: a role or service principal with read access to the objects Beacon should see, and nothing else (Snowflake: a role with USAGE + SELECT; BigQuery: BigQuery Data Viewer + BigQuery Job User on the project; Databricks: SELECT + USE CATALOG/USE SCHEMA through Unity Catalog).

EngineThe New data source dialog asks for
PostgreSQL, SQL Server, MySQL, Synapse, SnowflakeDatabase engine and connection string, plus metadata options: max tables, max columns per table, include and exclude schemas
DatabricksHost, HTTP path, personal access token; catalog and schema (optional)
BigQueryProject id, service-account JSON; dataset id and location (optional)
CloudWatchAWS region, log groups; access key id, secret access key or AWS profile (optional)
REST APIBase URL, OpenAPI spec URL, authentication (API key in a header or parameter, bearer token, or basic), include and exclude path patterns

The last step of the dialog runs Test connection before Create data source.

Queries may only name objects in the database (catalog, project) the data source is configured for: the gate refuses other databases, remote servers, files and dynamic SQL.

A query can have several steps on different data sources. Each step’s result is materialised (@result1, @result2, …) and a final query joins them in an in-memory SQLite database. Nothing is joined across engines at the database level, and the final query passes the same gate. See Queries.

Monitoring your own application’s database

Section titled “Monitoring your own application’s database”

To let Beacon (and MCP clients) read your application’s own EF Core model (with a table allow-list, column masking and a read-only connection string that is never stored) use ExposeDbContext<TContext>(...) instead of creating a data source by hand. See Extending Beacon.

  • MySQL carries the Pomelo EF Core provider (used for migration writes). Restore prints NU1608; suppress it if you treat warnings as errors.
  • Connector registration also fills process-wide registries (engine → connection factory). Register connectors once, at startup.
  • The data-quality SQL generator supports PostgreSQL, SQL Server and MySQL.