Skip to Content
Data ConnectivitySQL Connector

SQL Connector

The SQL Connector polls a relational database on a schedule and writes the results into the DataPool. It supports SQL Server, MySQL, PostgreSQL, and SQLite.

Connection Strings

Server=myserver.database.windows.net;Database=mydb;User Id=myuser;Password=mypassword;Encrypt=True;

Configuration

SettingDescriptionDefault
Connection StringDatabase connection string (see above)Required
QuerySQL SELECT statement to executeRequired
Polling IntervalHow often to run the query60 seconds
Stream NameDataPool stream name for the resultsRequired
Item Key ColumnColumn that uniquely identifies each rowFirst column
TimeoutQuery execution timeout30 seconds

Writing Queries

Write a standard SQL SELECT statement. Every column in the result set becomes a DataPool field.

SELECT RegionName AS region, TotalSales AS sales, Target AS target, ROUND((TotalSales / Target) * 100, 1) AS pct_of_target FROM SalesReport WHERE ReportDate = CAST(GETDATE() AS DATE) ORDER BY TotalSales DESC

Avoid queries that return large result sets. The SQL Connector is designed for summary/dashboard data, not bulk data transfer. Keep results under 1,000 rows for optimal performance.

Parameterised Queries

You can use parameters in your queries to make them dynamic:

ParameterValue
@todayCurrent date
@nowCurrent date and time
@yesterdayYesterday’s date
@startOfWeekStart of the current week
@startOfMonthStart of the current month

Example:

SELECT Department, HeadCount FROM StaffingLevels WHERE ReportDate = @today

Data Type Mapping

SQL TypeDataPool Type
INT, BIGINT, FLOAT, DECIMALNumber
VARCHAR, NVARCHAR, TEXT, CHARString
BIT, BOOLEANBoolean
DATE, DATETIME, TIMESTAMPDate
JSON, JSONBJSON

Error Handling

ErrorCauseSolution
Connection timeoutServer unreachableCheck network, firewall rules, server status
Authentication failedWrong credentialsVerify username and password
Query timeoutQuery too slowOptimise query, add indexes, increase timeout
Permission deniedInsufficient privilegesGrant SELECT permission to the database user

Best Practices

  • Use a read-only database user for security
  • Add indexes on columns used in WHERE clauses
  • Use views to simplify complex queries
  • Set polling interval based on how frequently the source data changes
  • Use column aliases (AS) to give fields meaningful names in the DataPool
Last updated on